[英]How to access a document library in a sharepoint online site using MS graph
I am able to access the documents on my one drive with requests like this one: 我可以使用以下请求访问我的一个驱动器上的文档:
https://graph.microsoft.com/v1.0/me/drive/root/children
I am able to access a document library of a root sharepoint site of my company with a request like this: 我能够通过以下请求访问公司的根共享点站点的文档库:
https://graph.microsoft.com/v1.0/drive/root/children
It gives me the contents of the "root" library: 它给了我“根”库的内容:
https://<my company>.sharepoint.com/Shared%20Documents
I am not able to access the document library of a SP subsite I created. 我无法访问我创建的SP子网站的文档库。 eg this one:
例如这一个:
https://<my company>.sharepoint.com/samplesp/Shared%20Documents
How can I access such a document library with MS Graph? 如何使用MS Graph访问这样的文档库?
For accessing SharePoint sites and lists check out documentation of the SharePoint API in Microsoft Graph . 要访问SharePoint网站和列表,请查看Microsoft Graph中的SharePoint API文档。
Update: 更新:
For those who have problems with accessing default Drive (formerly "Documents" library) on a specific SharePoint site using MS Graph API: 对于那些使用MS Graph API访问特定SharePoint站点上的默认驱动器(以前称为“文档”库)有问题的用户:
You should look into the documentation for accessing files on OneDrive . 您应该查看有关在OneDrive上访问文件的文档。
As said in the question, this endpoint gives us a list of files on private OneDrive: 如问题中所述,此端点为我们提供了私有OneDrive上的文件列表:
.../me/drive/root/children
Drive on SharePoint's sites works in the same way, but instead of me
you should provide global Id of the site you want to access ( global Id is <hostName>,<siteCollectionId>,<siteId>
). 开车在SharePoint网站上的作品以同样的方式,但不是
me
,你应该为你要访问的网站的全球ID( 全球编号为<hostName>,<siteCollectionId>,<siteId>
In conclusion: this endpoint gives us a list of files on a specified site's default drive: 总之:此端点为我们提供了指定站点的默认驱动器上的文件列表:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/drive/root/children
If you want to access files on a specific list, all you need is the id of the list: 如果要访问特定列表中的文件,您只需要列表的ID:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/lists/<listId>/drive/root/children
Now it should be obvious. 现在应该是显而易见的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.