Sameer
Sameer

Reputation: 3183

Downloading one drive file given a link in a single api call

I have an attachment link which points to user's onedrive .

https://company-my.sharepoint.com/personal/drive_name/Documents/Microsoft Teams Chat Files/hr.pak

While I can download this file by following series of steps:

  1. Getting user's driveid

GET https://graph.microsoft.com/v1.0/users/{idOrUserPrincipalName}/drive

  1. Get items from the root drive

GET https://graph.microsoft.com/v1.0/drives/{driveId}/root/children

  1. Get items of Microsoft Team Chat Files folder

GET https://graph.microsoft.com/v1.0/drives/{driveId}/items/{itemId}/children

  1. Download file using the value of @microsoft.graph.downloadUrl field.

Is it possible to translate the url(https://company-my.sharepoint.com/personal/drive_name/Documents/Microsoft Teams Chat Files/hr.pak) to a single graph api call to download the file?

Upvotes: 0

Views: 486

Answers (1)

Dot
Dot

Reputation: 26

Try:

https://graph.microsoft.com/v1.0/drives/DRIVE_ID/root:/FILE_PATH/hr.pak:/content

replace the words in CAPS with your details.

Upvotes: 1

Related Questions