0
votes

I have a Sharepoint with multiple drives that contains an Excel file (xlsx) of which I'd like to return some data.

I have successfully found the Excel file through lists with a GET: https://graph.microsoft.com/beta/sites/COMPANY.sharepoint.com:/teams/TEAM:/lists/LONGID/items/LONGID/

Which leads to the Excel file. If I try to start a session by POSTing to excelfile/workbook/createSession with { "persistChanges": false } as body, I get a "Resource not found for the segment 'workbook'" error.

Thinking it was because I was working with a listitem, I have been trying to find the file through the drive afterwards but any which way, I can not access any drives.

https://graph.microsoft.com/beta/sites/COMPANY.sharepoint.com:/teams/TEAM:/drives

Above link returns all the drives. Accessing a drive by going to

  • drives/LONGID/root
  • drives/LONGID/root/children
  • drives/LONGID/items
  • drive/LONGID/root
  • drive/LONGID/root/children
  • drive/LONGID/items

returns a "Url specified is invalid". It's the same for accessing files in the default drive.

Any help would be appreciated!

1
I believe there might be a problem with how URL's are handled. GETting sharepoint/lists works as well as sharepoint/lists/. GETting sharepoint/drives works but not sharepoint/drives/ This gives the invalid URL error. - JVan
Same issue as here. Using the new site format solved the issue. - JVan

1 Answers

1
votes

You have correctly guessed that in the first case you are querying listItem which is not a driveItem. You've gotten very close to figuring out the correct URL on your own.

What you can leverage is the fact that every SharePoint list is a drive. Then, you can do the following: GET https://graph.microsoft.com/beta/sites/SITE_ID/lists/LIST_ID/drive/items/ITEM_ID/workbook/worksheets.

I use the ID notation for shortness, but the :/path: notation works for sites, lists, and driveItems.

Let me know if this still doesn't work.

Thanks,
Zlatko