Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top