如何使用 MS Graph 访问共享点在线站点中的文档库
How to access a document library in a sharepoint online site using MS graph
我可以通过这样的请求访问我的一个驱动器上的文档:
https://graph.microsoft.com/v1.0/me/drive/root/children
我可以通过这样的请求访问我公司的根共享点站点的文档库:
https://graph.microsoft.com/v1.0/drive/root/children
它给了我 "root" 库的内容:
https://<my company>.sharepoint.com/Shared%20Documents
我无法访问我创建的 SP 子网站的文档库。例如这个:
https://<my company>.sharepoint.com/samplesp/Shared%20Documents
如何使用 MS Graph 访问这样的文档库?
要访问 SharePoint 网站和列表,请查看 SharePoint API in Microsoft Graph 的文档。
更新:
对于那些在使用 MS Graph API 访问特定 SharePoint 站点上的默认驱动器(以前的 "Documents" 库)时遇到问题的用户:
您应该查看 OneDrive 上有关访问文件的文档。
如问题中所述,此端点为我们提供了私有 OneDrive 上的文件列表:
.../me/drive/root/children
SharePoint 网站上的驱动器以相同的方式工作,但您应该提供要访问的网站的 全局 ID 而不是 me
(全局 ID 是 <hostName>,<siteCollectionId>,<siteId>
).
总而言之:此端点为我们提供了指定站点默认驱动器上的文件列表:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/drive/root/children
如果你想访问特定列表中的文件,你只需要列表的id:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/lists/<listId>/drive/root/children
现在应该很明显了。
我可以通过这样的请求访问我的一个驱动器上的文档:
https://graph.microsoft.com/v1.0/me/drive/root/children
我可以通过这样的请求访问我公司的根共享点站点的文档库:
https://graph.microsoft.com/v1.0/drive/root/children
它给了我 "root" 库的内容:
https://<my company>.sharepoint.com/Shared%20Documents
我无法访问我创建的 SP 子网站的文档库。例如这个:
https://<my company>.sharepoint.com/samplesp/Shared%20Documents
如何使用 MS Graph 访问这样的文档库?
要访问 SharePoint 网站和列表,请查看 SharePoint API in Microsoft Graph 的文档。
更新:
对于那些在使用 MS Graph API 访问特定 SharePoint 站点上的默认驱动器(以前的 "Documents" 库)时遇到问题的用户:
您应该查看 OneDrive 上有关访问文件的文档。
如问题中所述,此端点为我们提供了私有 OneDrive 上的文件列表:
.../me/drive/root/children
SharePoint 网站上的驱动器以相同的方式工作,但您应该提供要访问的网站的 全局 ID 而不是 me
(全局 ID 是 <hostName>,<siteCollectionId>,<siteId>
).
总而言之:此端点为我们提供了指定站点默认驱动器上的文件列表:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/drive/root/children
如果你想访问特定列表中的文件,你只需要列表的id:
.../Sharepoint/sites/<hostName>,<siteCollectionId>,<siteId>/lists/<listId>/drive/root/children
现在应该很明显了。