List folder contents of 'Shared with Me' folder from Office 365 OneDrive (Sharepoint) for Business and Education using the REST api?

▼魔方 西西 提交于 2019-11-30 19:18:08

问题


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

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


回答1:


Found the solution to this...

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})'

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

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


来源:https://stackoverflow.com/questions/28221359/list-folder-contents-of-shared-with-me-folder-from-office-365-onedrive-sharep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!