Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Sharepoint site's document library via Microsoft Graph API?

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.

like image 803
jagmohan Avatar asked Apr 03 '17 13:04

jagmohan


2 Answers

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.

like image 114
Ravi Anand Avatar answered Oct 19 '22 23:10

Ravi Anand


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.

like image 40
jagmohan Avatar answered Oct 20 '22 01:10

jagmohan