Create upload session with item-id returns "invalid request" with valid payload but actual response with wrong format payload

Divya S Prasad 21 Reputation points
2021-06-18T11:33:01.21+00:00

Hi,

I'm trying to upload a file to one drive through code and these are my observations while testing the API with postman.

POST url : https://graph.microsoft.com/v1.0/me/drive/items/{item-id}:/{filename}:/createUploadSession

Authorization : Bearer token added

Expected payload format from documentation :

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

But when I call the api with payload in expected format, I receive "invalid request" as response.

When I pass payload as below: (without external curly braces)

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

Upload session is created and required response is obtained.

With Microsoft graph explorer, in both the cases I'm not able to create upload session but I receive invalid request as response.

API works as expected when I try to create upload session with file path, but the payload problem occurs when I try to create session with item-id.

Request you to kindly look into this, fix if required and please let me know about the right approach and correct me if my understanding is wrong.

Thanks
Divya

107111-payload.png

106970-payloadwithoutbraces.png

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Divya S Prasad 21 Reputation points
    2021-06-19T09:15:08.79+00:00

    Found my answer.

    Request body is optional for create upload session call. Hence with invalid payload, payload was not added to the request and upload session got created without payload.

    Regarding item object in payload : I retained just conflict behavior and file name attributes and it worked fine.

    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.