김세림
김세림

Reputation: 311

A 400 error occurs when creating a OneDrive API upload session

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://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-beta#create-an-upload-session

Upvotes: 1

Views: 1469

Answers (1)

Brad
Brad

Reputation: 4192

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.

Upvotes: 2

Related Questions