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

前端 未结 1 1526
青春惊慌失措
青春惊慌失措 2021-01-06 21:42

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

相关标签:
1条回答
  • 2021-01-06 22:20

    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
    
    0 讨论(0)
提交回复
热议问题