I am using the following method in a web browser to fetch file contents of a DriveItem using the Microsoft Graph:
GET /drives/{drive-id}/items/{item-id}
// Get the @microsoft.graph.downloadUrl property of the returned DriveItem
GET {downloadUrl}
This requires two GET
calls.
I am also aware of this API:
GET /drives/{drive-id}/items/{item-id}/content
As documented here:
Download the contents of a DriveItem.
But the /content
endpoint has two problems:
- It returns a 302 Found response, causing a redirect which needs another roundtrip to fetch the contents
- The API doesn't work in a JavaScript application using XHR as mentioned in this article: OneDrive - CORS support
How can I fetch the file contents of a DriveItem in one request?