1

If we are crawling sharepoint online, we can access these data from API using:

  • MS graph API or
  • SharePoint REST API (CSOM, ODATA)

All of our code uses the CSOM rest API for SharePoint.

But, for each list item in a list, we would like to get the Graph ID that corresponds to the List Item ID. That way, we store an ID that is compatible with the MS Graph API in case we want to look up that document there.

Do SharePoint list item fields available from the Rest APIs contain a field with the MS graph id for the list item?

UPDATE:

After some research, I believe I was using the incorrect terminology for "Graph ID." Sounds like the correct terminology is "OneDrive Item ID" and they look like this: 01JSWLMSD5CVNHFLHNDNGLWP2WGNNGDEG2

2 Answers 2

2

I found out how to get it. It's in fields on the SP.File object: VroomItemID and VroomDriveID.

    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"></View>";
    ListItemCollection collListItem = list.GetItems(camlQuery);
    clientContext.Load(collListItem,
      listItems => listItems.Include(
          listItem => listItem.File.VroomItemID,
          listItem => listItem.File.VroomDriveID
        ));
    clientContext.ExecuteQuery();
1
  • 1
    Interesting. I wasn't aware of those properties on the SP.File object. Thank you for posting the solution. Apr 1, 2022 at 12:54
1

Not sure what you mean by "Graph ID". The item ID for a list item is the same regardless of the API.

Maybe this will help. If I access the item in the Documents library with the item ID equal 1 using this REST API request

https://robwindsortest991.sharepoint.com/sites/Demo/_api/Web/Lists/GetByTitle('Documents')/Items(1)

Then I can access the same item using this Microsoft Graph request

https://graph.microsoft.com/v1.0/sites/robwindsortest991.sharepoint.com:/sites/Demo:/Lists/Documents/Items/1

In both cases, the item ID is 1.

Does that help?

3
  • I should have specified. this is the ItemID. I'm looking for something unique. It appears that MS graph api has a unique ID form, as talked about here: stackoverflow.com/questions/49011662/… and in that example it was "01JSWLMSD5CVNHFLHNDNGLWP2WGNNGDEG2" Mar 24, 2022 at 19:37
  • I think you can still get the response you want using the list item ID. Just append driveItem to the Graph request I included in my answer. Mar 24, 2022 at 20:59
  • 1
    It's the third HTTP request option from the bottom docs.microsoft.com/en-us/graph/api/… Mar 24, 2022 at 21:01

Your Answer

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

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