【发布时间】:2015-01-29 17:54:22
【问题描述】:
有没有办法从 Office 365 (Sharepoint) REST api 获取“与我共享”文件夹的内容?
我在 api 参考中看不到任何内容。 https://msdn.microsoft.com/office/office365/APi/files-rest-operations
【问题讨论】:
标签: rest sharepoint office365 onedrive
有没有办法从 Office 365 (Sharepoint) REST api 获取“与我共享”文件夹的内容?
我在 api 参考中看不到任何内容。 https://msdn.microsoft.com/office/office365/APi/files-rest-operations
【问题讨论】:
标签: rest sharepoint office365 onedrive
找到了解决办法...
您必须使用共享点搜索 API,而不是使用文件 API。 以下带有 KQL 查询参数的端点可用于获取“与我共享”的文件列表
https://{tenant}-my.sharepoint.com/_api/search/query?querytext='(SharedWithUsersOWSUSER:{UserAccountName} AND contentclass:STS_ListItem_MySiteDocumentLibrary)'
以上将获得“与我共享”的文件列表,但不会获得共享文件夹中的任何内容。要获取共享文件夹中的项目,您可以使用以下端点。
https://{tenant}-my.sharepoint.com/_api/search/query?querytext='(ParentLink:{ParentLink})'
确保父链接是 url 编码的。您可以从文件夹属性中检索父链接。
最后要获取第一个请求中使用的帐户名称,您可以向 sharepoint webs api 发出请求。
https://{tenant}-my.sharepoint.com/_api/web/CurrentUser
【讨论】: