11
votes

I'm working on accessing document libraries for Sharepoint sites via Mircosoft Graph, but haven't had any luck so far.

Here is my setup:

I have two sites

https://mydomain.sharepoint.com

https://mydomain.sharepoint.com/teams/MyTestSite

When I make an api call to https://graph.microsoft.com/v1.0/drives, the response doesn't contain id of document library for second site (https://mydomain.sharepoint.com/teams/MyTestSite).

I have gone through documentation and haven't found anything on how to accomplish this. If anyone got any idea about this, please share.

Thanks.

3

3 Answers

3
votes

I was able to figure out a solution for this. A sharepoint site is represented as a Group in Office 365. I found that out by doing some hit and trial.

enter image description here

So, after looking up their documentation for anything related to a Group, I got to this: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/group

And, by using the List groups endpoint I was finally able to get a list of all the Sharepoint sites which the authenticated user can access.

This API call requires Group.Read.All scope while requesting access token and only Admin users can authorize this scope. So, this will need a separate interface for Admin to list groups, potentially store the group-user mapping on my app for the user to be able to make api call (/groups/{group-id}/drive/items/{item-id}) related to the drive.

1
votes

The V1.0 API has a way to list your doc lib as follows

GET https://graph.microsoft.com/v1.0/sites/mydomain.sharepoint.com:/Teams/MyTestSite:/drives

Hope this helps.

0
votes

The beta API also exposes a Sharepoint endpoint.

You can also use the path if you already know your site structure:

GET https://graph.microsoft.com/beta/sharepoint:/sites