0
votes

Create an upload session to upload large files to oneDrive.

Below is the request address.

https://graph.microsoft.com/beta/users/{userId}/drive/root:/UploadFiles/{fileName}:/createUploadSession

Request Body

  {
 "item": {
"@odata.type": "microsoft.graph.driveItemUploadableProperties",
"@microsoft.graph.conflictBehavior": "rename",
"name": "largefile.dat"
 }
}

An Invalid request error occurs. What's wrong with it? I watched the tutorial and tested it.

POST /drive/root:/{item-path}:/createUploadSession Content-Type: application/json

{
"item": {
"@odata.type": "microsoft.graph.driveItemUploadableProperties",
"@microsoft.graph.conflictBehavior": "rename",
"name": "largefile.dat"
}

}

https://docs.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-beta#create-an-upload-session

1
The 400 response should include a JSON body with details of the failure - do you have an example?Brad
@Brad { "error": { "code": "invalidRequest", "message": "Invalid request", "innerError": { "date": "2020-10-15T04:24:49", "request-id": "2733aaad-cb81-4762-acb5-cc069b44ddb2", "client-request-id": "3cd178ab-3315-c047-cab8-20b1c8166ec4" } } }김세림
Please remove the odata.type property and give it a try. It worked for me.Shiva Keshav Varma

1 Answers

2
votes

As Shiva suggested in a comment on the question, the issue is that the value of @odata.type is not correct for this case. In general you should not provide it at all as the schema is strongly typed and therefore the appropriate value can be derived without any client-driven hints.