1

I am using REST service call to get items. I need to check if the item has any published version in filter part of url. I just need to filter based on this value. I don't need version history. I checked that we have HasPublishedVersion property in SPListItem. Is there any similar column that I can use in REST url? or is there any way I can check for published version in REST?

1 Answer 1

3

The following REST URL will give you the byte to indicate whether it is published / is a Draft / is checked out.

http://siteurl/_api/web/getfilebyserverrelativeurl('Serverrelativeurl')?$select=Level

And according to MSDN,

Level: Gets a value that specifies the publishing level of the file. Represents an SP.FileLevel value: Published = 1; Draft = 2; Checkout = 255.

As the items REST endpoint that you are using does not have this property, you could get the server relative URL as below and then feed it into getfilebyserverrelativeurl to get the publishing status:

http://siteurl/_api/web/lists/getbytitle('ListTitle')/items?$select=FileRef
1
  • It works well except one scenario. when I create a new draft version for published item, it returns me byte value 2. HasPublishedVersion gives result true if it has any published version and even its current status is draft. Oct 8, 2015 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.