Forum Discussion
Aidan-aaa
Dec 04, 2024Copper Contributor
Get all versions' check-in comments through API
I'm trying to use the REST API through Power Query to get all history check-in comments of an item.
I could see all the comments from the version history
but output of the API shows the lastest comment for the both two versions:
I'm using a Power Query function I get from the Power BI forum and all other things it returns are correct, except the check-in comments
let
Source = (VersionsRelevantSharePointListName as text, VersionsRelevantSharePointLocation as text, VersionsRelevantItemID as number) => let
Source = Xml.Tables(Web.Contents(
"https://tenatename.sharepoint.com/sites/",
[RelativePath = VersionsRelevantSharePointLocation & "/_api/web/Lists/getbytitle('" & VersionsRelevantSharePointListName & "')/items(" & Text.From(VersionsRelevantItemID) & ")/versions"]
)),
entry = Source{0}[entry],
#"Removed Other Columns2" = Table.SelectColumns(entry,{"content"}),
#"Expanded content" = Table.ExpandTableColumn(#"Removed Other Columns2", "content", {"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"}, {"content"}),
#"Expanded content1" = Table.ExpandTableColumn(#"Expanded content", "content", {"properties"}, {"properties"}),
#"Expanded properties" = Table.ExpandTableColumn(#"Expanded content1", "properties", {"http://schemas.microsoft.com/ado/2007/08/dataservices"}, {"properties"})
in
#"Expanded properties"
in
SourceDoes this API support return all comments? Or I need to get all comments from elsewhere.
1 Reply
Make use of M-code:
Had this on an old project code of mine, it should work:
let SiteUrl = "https://<your-sharepoint-site>", ListName = "<list-name>", ItemId = "<item-id>", Endpoint = SiteUrl & "/_api/web/lists/getbytitle('" & ListName & "')/items(" & ItemId & ")/versions", Source = OData.Feed(Endpoint), VersionsTable = Source[results], ExpandedVersions = Table.ExpandRecordColumn(VersionsTable, {"VersionLabel", "CheckInComment", "Created"}, {"Version", "Comment", "Timestamp"}) in ExpandedVersions