How to share a file in onedrive using API ?

Aman Singh 31 Reputation points
2021-09-03T12:05:25.693+00:00

I am currently my organization work account and using this API for sharing - https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_invite?view=odsp-graph-online

The request is successful but the shared user not able to see/find the file in its shared folder.

Is there any other way to do it or I am missing something here ?

Also, Is the API works differently for work accounts and personal accounts ?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,060 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Choudhary 601 Reputation points Microsoft Employee
    2021-09-06T09:12:39.233+00:00

    Thank you for reaching out.

    Few things that could help here -

    1. Try accessing the shared drive items as described here.
    2. Do keep in mind, for OneDrive for Business and SharePoint, the Shares API always requires authentication and cannot be used to access anonymously shared content without a user context.
    3. Check the roles that are to be granted to the recipients of the sharing invitation. Do note that drives with a driveType of personal (OneDrive personal) cannot create or modify permissions on the root DriveItem.
    4. Look out for 'sendInvitation' parameter in the request body. If true, a sharing link is sent to the recipient. Otherwise, permission is granted directly without sending a notification.

    If this doesn't help, please reach out including details of an API call (timestamp, client request-id, request body, and response).

    0 comments No comments