using microsoft graph to get versioning infomation

Ian.Mahern-Macias 0 Reputation points
2023-03-31T17:47:10.6266667+00:00

I am currently working to try and use Microsoft graph to reliable report to me the size of a file, the total number of versions for that file, and the total space that all the versions combined take up for all files for a site/site collection

I am reviewing a lot of the QA questions here and I cannot seem to find anyone trying to do something similar with this tool.
I know there are powershell script for this but due to the size of some of our site collections it takes a very long to run this and I believe that the graph API should be quicker.

does anyone have any starting advice? is this something the Microsoft Graph can do?

Thank you

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,447 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CharanyaB-MSFT 1,886 Reputation points Microsoft Vendor
    2023-04-03T07:02:46.4766667+00:00

    Hello @Ian.Mahern-Macias,

    Thanks for reaching out!

    You can use GET /sites/{site-id}/drive/items/{item-id}/versions API to fetch the versions of OneDrive or SharePoint items. This API lists all versions and gives the size of each version. But currently, this doesn't fetch the total space of all the versions combined. Please refer to the below documents for more details about fetching the versions of an item using Graph API:

    https://learn.microsoft.com/en-us/graph/api/driveitem-list-versions?view=graph-rest-1.0&tabs=http

    https://learn.microsoft.com/en-us/graph/api/resources/driveitemversion?view=graph-rest-1.0

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments