Explicitly sharing files externally

SCT-Akouodev 26 Reputation points

Requirement: Let user A (in tenant/org Y) share a file with user B (in tenant/org Z) and allow user B to access or copy this file to their storage programmatically.

Can this be achieved? I have tried the following -
"/copy" endpoint with either user's authentication results in 404 error - The resource could not be found.

"/invite" endpoint with user A's authentication, then "/sharedWithMe?external=true" with user B's authentication - does not list the shared file.

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
8,994 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,449 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,686 Reputation points Microsoft Vendor

    Hi @SCT-Akouodev ,

    By default, sharedWithMe return items shared within your own tenant. To include items shared from external tenants, append ?allowexternal=true to the GET request.

    Looking at your question you seem to use wrong parameter in your API call /sharedWithMe?external=true, please find the correct parameter /sharedWithMe?allowexternal=true.

    Also, make sure in the request payload of /invite API, use "requireSignIn": true so the file appears in OneDrive shared files.

    POST /drive/items/{itemId}/invite  
        "requireSignIn": true,  
        "sendInvitation": true,  
        "roles": [ "read" ],  
        "recipients": [  
                "email": "string"  
        "message": "string"  

    For more information please refer these documentations.

    Hope this helps you.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".