1

I am trying to retrieve comments from my previous check in's in a library file in SharePoint Online.

In SharePoint Online I can see the Check in comments successfully present in all the file versions but by using REST API I can only see the last check in comment getting duplicated in every version.

For example, in SharePoint there are these versions details: enter image description here

You can see that version 5.0 has "WENARDO 2" as a check in comment value and the last version (7.0) has "test".

But by the following REST query,

[siteurl]/_api/web/lists/getbytitle('[library]')/items([id])/versions?$expand=Fields,Attachments

I am getting these values:

var results = response.map(function(item) {return item.OData__x005f_CheckinComment});
console.log(results); 

["test", "test", "test", "test", "test", "test", "test", "test"]

As you can see, I am getting the last Check in Comment for every version.

In fact, in the JSON response, there is no match for the text "WENARDO" or "WENARDO 2".

How can I get those values using REST?

Thanks in advance.

1 Answer 1

1

I can confirm the same behavior in multiple tenants when using the items([id])/versions REST API.

However, by calling the Versions method on the File, instead of the Item, I do get valid CheckinComments. Unfortunately, you do not get most of the metadata for the item, and you do not get the "current" version, but his API call will get all CheckinComments for previous versions:

[siteurl]/_api/web/GetFileByServerRelativeUrl('[ServerRelativeFileUrl]')/Versions
2
  • In that case using this REST API and the items([id])/versions by matching the VersionLabel I could retrieve all the metadata I need. Thanks!
    – chestacio
    Feb 24, 2020 at 22:05
  • Does this work with SharePoint 2013?
    – Paul Vu
    May 27, 2020 at 18:12

Your Answer

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

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