Shared With Me files are not getting in API response

Casepoint Developer 66 Reputation points
2024-07-16T18:42:39.3433333+00:00

Using client credential authentication flow we are trying to get SharedWithMe files of user but we are getting empty response although the user has files in sharedWithMe

API we are using: https://graph.microsoft.com/v1.0/users/{0}/drive/sharedWithMe

API response:

API Response

Although user have data in onedrive

Data in Onedrive UI

Thanks & Regards,

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,419 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
974 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,273 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 2,335 Reputation points Microsoft Vendor
    2024-07-17T01:54:39.0966667+00:00

    Hi @Casepoint Developer

    According to the documentation, the endpoint does not support the use of client credential flow, after testing, although the request can be successful, but will not return any data, please use auth code flow, the request path is as follows:

    GET https://graph.microsoft.com/v1.0/me/drive/sharedWithMe
    

    After testing the request worked very well, here are the results of my tests in Graph Explorer:

    Screenshot 2024-07-17 095017

    See this link for more details:

    https://learn.microsoft.com/en-us/graph/api/drive-sharedwithme?view=graph-rest-1.0&tabs=http

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.