使用 REST api 列出 Office 365 OneDrive (Sharepoint) for Business 和 Education 中“与我共享"文件夹的文件夹内容? [英] List folder contents of 'Shared with Me' folder from Office 365 OneDrive (Sharepoint) for Business and Education using the REST api?

查看:23
本文介绍了使用 REST api 列出 Office 365 OneDrive (Sharepoint) for Business 和 Education 中“与我共享"文件夹的文件夹内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从 Office 365 (Sharepoint) REST api 获取与我共享"文件夹的内容?

Is there a way to get the contents of the 'Shared with Me' folder from the Office 365 (Sharepoint) REST api ?

我在 api 参考中看不到任何有关此内容的内容.https://msdn.microsoft.com/office/office365/APi/files-休息操作

I can't see anything in the api reference reagrding this. https://msdn.microsoft.com/office/office365/APi/files-rest-operations

推荐答案

找到了解决方案...

您必须使用 sharepoint 搜索 api,而不是使用文件 api.以下带有 KQL 查询参数的端点可用于获取与我共享"的文件列表

Instead of using the files api you must use the sharepoint search api. The following endpoint with the KQL query parameters can be used to get a list of files 'shared with me'

https://{tenant}-my.sharepoint.com/_api/search/query?querytext='(SharedWithUsersOWSUSER:{UserAccountName} AND contentclass:STS_ListItem_MySiteDocumentLibrary)'

以上将获得与我共享"的文件列表,但不会获得共享文件夹中的任何内容.要获取共享文件夹中的项目,您可以使用以下端点.

This above will get a list of files 'shared with me' but not anything inside a shared folder. To get the items inside a shared folder you can use the following endpoint.

https://{tenant}-my.sharepoint.com/_api/search/query?querytext='(ParentLink:{ParentLink})'

确保父链接是 url 编码的.您可以从文件夹属性中检索父链接.

Make sure the parent link is url encoded. You can retrieve the parent link from the folder properties.

最后要获取第一个请求中使用的帐户名称,您可以向 sharepoint webs api 发出请求.

Finally to get the account name used in the first request you can make a request to the sharepoint webs api.

https://{tenant}-my.sharepoint.com/_api/web/CurrentUser

这篇关于使用 REST api 列出 Office 365 OneDrive (Sharepoint) for Business 和 Education 中“与我共享"文件夹的文件夹内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆