首页 文章

使用REST API从Office 365 OneDrive(Sharepoint)for Business和Education列出'Shared with Me'文件夹的文件夹内容?

提问于
浏览
2

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

我在api引用中看不到任何重复此内容的内容 . https://msdn.microsoft.com/office/office365/APi/files-rest-operations

1 回答

  • 2

    找到解决方案......

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

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

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

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

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

    最后,为了获得第一个请求中使用的帐户名,您可以向sharepoint网站api发出请求 .

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

相关问题