Download Sharepoint and OneDrive files from MS Graph API returning Error 400

Edwin Fajar 146 Reputation points
2021-07-05T10:42:30.237+00:00

Previously, I have no problem when downloading Sharepoint and OneDrive files from MS Graph API using this endpoint Download the contents of a DriveItem. But since the 3rd of July 2021, I got Error 400 when downloading the file.

I tried to hit these endpoints using Application Permission and have Files.ReadWrite.All roles

GET /sites/{siteId}/drive/items/{item-id}/content
GET /users/{userId}/drive/items/{item-id}/content

And also tried to make a request directly to the URL from @microsoft.graph.downloadUrl property and got the same Error 400 result with this body.

{  
  "error": {  
    "code": "invalidRequest",  
    "innerError": {  
      "code": "badArgument"  
    },  
    "message": "One of the provided arguments is not acceptable."  
  }  
}  

I also see something strange from the response header at docID value. Usually, it has our site id value, but this one has value like this. The 00000000-0000-0000-0000-000000000000 seems like a dummy value.

XXXXX-my.sharepoint.com_00000000-0000-0000-0000-000000000000_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Any idea what is the cause? Is there any bug? Or I should add more property to the header?
Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,056 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,989 questions
0 comments No comments
{count} votes

Accepted answer
  1. Edwin Fajar 146 Reputation points
    2021-07-07T02:09:39.45+00:00

    Hi @MichaelHan-MSFT ,

    Like @Andriejus said, we have another tenant where the download file works and there are several tenants that also didn't works.
    But I just check again this morning and now the download file works. I will check again for another tenant that has the same issue before.

    Thank you for your reply.


5 additional answers

Sort by: Most helpful
  1. MichaelHan-MSFT 18,036 Reputation points
    2021-07-06T08:21:24.07+00:00

    Hi @Edwin Fajar ,

    Just did a test on my tenant. The endpoint to Download file works on my end. Also I could download the file with the URL from @microsoft.graph.downloadUrl property.

    Let me check more about this issue.

    1 person found this answer helpful.

Your answer

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