0

My clients shared some onedrive folder with me which contains 5 Files, I want to find the drive-Id, File-Id, so that I can download using python scripts, Script reference: Not able to download files from inside folder, OneDrive, Microsoft Graph, Python

I am trying below script:

requests.get('https://graph.microsoft.com/v1.0/me/drive/sharedWithMe', headers={'Authorization': 'Bearer ' + Access_Token}).content

requests.get('https://graph.microsoft.com/v1.0/me/drives', headers={'Authorization': 'Bearer ' + Access_Token}).content

but I am getting my files details only.

Learnings
  • 2,780
  • 9
  • 35
  • 55

1 Answers1

0

You can call the uri https://graph.microsoft.com/v1.0/me/drive/sharedWithMe first and get the response data. In the response, we can find the id and driveId(the "driveId" is under "remoteItem" -> "parentReference") of the shared file. And then use the api below to download its content.

https://graph.microsoft.com/v1.0/me/drives/{driveId}/items/{id}/content
Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • Thanks for reply, but I got blank in value ("value":[]): b'{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)","value":[]}' – Learnings May 11 '20 at 04:56
  • @SPy Which api did you request to get the blank value ? – Hury Shen May 11 '20 at 05:01
  • @Hurry Shen I have hit https://graph.microsoft.com/v1.0/me/drive/sharedWithMe – Learnings May 11 '20 at 05:17
  • It was shared from other domain, not in same domain, Like Client Shared file to their Partner – Learnings May 11 '20 at 05:18
  • @SPy Can you see the shared file in your onedrive "Shared with me" in browser ? – Hury Shen May 11 '20 at 05:26
  • @Hurry Shen No, Its not showing in "Shared with you", Client Shared their onedrive folder to my microsoft account and I am login using client URL that I got mail, not in my Drive. may be this is the issue – Learnings May 11 '20 at 05:31
  • @SPy It seems the client just share the link with you and the file doesn't exist in your onedrive. So we may not access the file according to some api. – Hury Shen May 12 '20 at 01:41