Microsoft Graph API - Office 365 Access SharePoint

2019-06-06 01:16发布

I was shared access to a SharePoint folder on our Office 365 site.

The folder is deeply nested. Something like:

http://mycorp.sharepoint.com

Our Docs > Marketing > Company > Images

Inside the "Images" folder are a list of JPGs.

How can I use the Graph API to access this deeply nested folder?

I've tried something like:

https://graph.microsoft.com/v1.0/sites/mycorp.sharepoint.com:/Documents/Marketing/Company/Images:/Items

I feel I'm close but I'm just not sure how to access the nested folder structure.

1条回答
在下西门庆
2楼-- · 2019-06-06 01:24

The format for referencing a path looks like this:

/v1.0/sites/root/drive/root:/{folder path}:/children

Using your example we have the following:

  1. https://graph.microsoft.com/v1.0/sites/root returns the root site of your SharePoint tenant.

  2. /drive/root returns default Drive for the Site. In this case, /Documents isn't actually a "folder", it's the default Drive for your root SharePoint

  3. :{folder path}: should be replaced by the path to the folder you're looking for. In this case /Marketing/Company/Images. The first : operator tells SharePoint to treat the following string as a file path. The second : tells SharePoint where the file path string ends.

  4. /children returns a list of DriveItem resources within the folder.

So you're complete URI should look something like this:

/v1.0/sites/root/drive/root:/Marketing/Company/Images:/children
查看更多
登录 后发表回答