I am trying to retrieve a list of DocumentSetVersions for a specific list item in a SharePoint site using the Microsoft Graph SDK, following the official Microsoft documentation here. However, when attempting to make the API call, I encounter an error.
The SharePoint list is a default document library with version control enabled.
I already implemented other api calls with the same GraphClient, siteId and ListId and it worked perfectly fine. Im sure that the listItemId is correct.
This is the code:
var result = await _graphClient.Sites[siteId].Lists[listId].Items[itemId].DocumentSetVersions.GetAsync();
The error returned is:
ODataError: One of the Provided arguments is not acceptable.
You can read documentSetVersions
only for list items that represents a folder. If the list item represents a file, the Graph API will return the error
ODataError: One of the Provided arguments is not acceptable.
Try to read first list item and check the contentType
property
var item = await _graphClient.Sites[siteId].Lists[listId].Items[itemId]
// check content type
item.ContentType.Name