Share via

GRAPH API access shared file from external tenant

LamDo-4943 0 Reputation points
2023-05-16T12:02:55.68+00:00

I am trying to get shared files from shared folder of external tenant.

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

Call GET /me/drive/sharedWithMe?allowexternal=true

I can get the top folder in shared-folder (with remoteItem)


{
  "value": [
    {
      "id": "1312ghi",
      ...,
      "remoteItem": {
        "id": "987def!654",
        "name": "Top FFol",
        "folder": {
          "childCount": 63
        },
        "size": 145362,
        "parentReference": {
          "driveId": "987def",
          "id": "987def!321"
        }
      }
    }
  ]
}

However, when I try to call for the detail GET https://graph.microsoft.com/v1.0/drives/987def/items/987def!654

https://graph.microsoft.com/v1.0/drives/987def/items/987def!654/children

It returns itemNotFound


{
    "error": {
        "code": "itemNotFound",
        "message": "Item not found",
        "innerError": {
            "date": "2023-05-16T11:34:56"
        }
    }
}

I dont know if any permission missing? I am able to see the shared-folder/sub files in OneDrive WebUI, and I can get the top folders from the shared-folder from the api, but why can not get the detail or list of children through api?

Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-05-16T17:09:08.3566667+00:00

    Hello Lam Do,
    Thank you for reaching out.

    Driver Details endpoint (/drives/{drive-id}/items/{item-id}/children or /drives/{drive-id}/items/{item-id}) will allow you to get details of internal shared link file. You can get details of shared file by an external with below endpoint only.
    https://graph.microsoft.com/v1.0/me/drive/sharedWithMe?allowexternal=true

    Hope this helps.
    Thanks.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.