When I try to download an .xlsx file from my sharepoint online through graph api using below url
https://graph.microsoft.com/v1.0/sites/sitename.sharepoint.com/drives/drive-id/items/item-id/content
I get the below error
{
"error": {
"code": "invalidRequest",
"message": "Provided identifier is malformed - site collection id is not valid",
"innerError": {
"request-id": "b5079821-3f5e-427f-96c2-ddb6993b1xxx",
"date": "2019-11-27T22:22:40"
}
}
}
I can view that file is valid with the following url https://graph.microsoft.com/v1.0/sites/sitename.sharepoint.com/drives/drive-id/items/item-id
Thank you for your contribution to OneDrive API Docs. We will be triaging your incoming issue as soon as possible.
This looks like a bug - for a workaround you'll need to make a request like this:
and then use the URL in the @microsoft.graph.downloadUrl property to retrieve the content.
I am also facing the same issue, and I can't use your workaround as well as I want to download in a given format (PDF in my case).
I'm also facing this issue, and need to use this endpoint. Is there any news on how/when it will be fixed?
In my case I was not using the correct id. The id is not the site id, instead its a combination of 3 values.
I found the id using Microsoft Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer), log in with the O365 admin account and calling this url: https://graph.microsoft.com/v1.0/sites/YOUR_SHAREPOINT_URL/:/sites/NAME_OF_SITE/?$select=id where YOUR_SHAREPOINT_URL is something like testshare.sharepoint.com.
Thanks to: https://medium.com/medialesson/convert-files-to-pdf-using-microsoft-graph-azure-functions-20bc84d2adc4
Another work around is to avoid going through sites if you don't need to. For example, if you have the driveid you can simply do:
GET https://graph.microsoft.com/v1.0/drives/driveid/items/itemid/content
However, we just pushed through a change that should help fix the syntax shown in the original issue description, and it should be deployed in a couple of weeks.
In my case I was not using the correct id. The id is not the site id, instead its a combination of 3 values.
I found the id using Microsoft Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer), log in with the O365 admin account and calling this url: https://graph.microsoft.com/v1.0/sites/YOUR_SHAREPOINT_URL/:/sites/NAME_OF_SITE/?$select=id where YOUR_SHAREPOINT_URL is something like testshare.sharepoint.com.
Thanks to: https://medium.com/medialesson/convert-files-to-pdf-using-microsoft-graph-azure-functions-20bc84d2adc4
Thanks =),
I got the "id" from https://graph.microsoft.com/v1.0/sites/root
But it seems like I can use the first value out of 3 when requesting other endpoints successfully, but not for the download endpoint. But it worked when I'm using all those 3 values as the "siteId"
FYI providing only the hostname for the siteid should now hopefully work - can someone confirm that the scenario looks good?
@ificator I can confirm that this is now working 馃憤