onedrive-api-docs: How to setup createUploadSession when sending a (new) file to a shared folder (400 Bad Request error)

Although official documentation quite rich, I can’t find any details of how exactly I should upload the large file to a shared folder (not to my drive).

I’ve followed the docs:

POST /drives/{driveId}/items/{itemId}/createUploadSession

{"Item":{"@microsoft.graph.conflictBehavior":"replace","name":"20200310-155252-700.jpg"}}

Where the itemId is the folder id I am trying to upload that file to.

However, it returns 400 Bad Request error Name from path does not match name from body message.

But the request path provided in docs doesn’t expect passing the file name at all!

I kind of suspecting that the itemId should be an existing item on the drive (not even inside the folder), rather than a folder id to create that file in, but a) I am not sure about that and b) how is it possible to have an empty file without any content before having that upload complete (again, if I am right about b)).

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@alextricity25, Hallelujah, I’ve finally found the solution myself! This is just an issue with their documentation. It seem has such low quality unlike of many other products! So, the correct request url must be as follows (instead of what’s said in the docs): $"{baseUrl}/drives/{drive}/items/{itemId}:/{fileName}:/createUploadSession"

It worked for me well.

After two weeks and “rapid” help from Microsoft, I’ve found the solution myself. Thanks [not] guys for helping on a primitive question! Well done!

I’m seeing the same thing when trying to create an upload session on a shared folder.

The request is quite simple and straight forward:

 POST /v1.0/drives/b!K.....iY/items/01JGS.....WGFD/createUploadSession https/1.1
 Host: https://graph.microsoft.com
 Authorization: Bearer ey...A
 Content-Type: application/json; charset=utf-8
 Content:
 {"Item":{"@microsoft.graph.conflictBehavior":"replace","name":"20200311-173207-250.jpg"}}

Response:

 Duration: 00:00:01.3050835
 HTTPS/1.1 400 Bad Request
 Cache-Control: private
 request-id: 4e416429-1c80-40d8-b559-fa90213c6197
 client-request-id: 4e416429-1c80-40d8-b559-fa90213c6197
 x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"003","RoleInstance":"AGSFE_IN_29"}}
 Strict-Transport-Security: max-age=31536000
 Date: Wed, 11 Mar 2020 17:32:07 GMT
 Content-Type: application/json
 Content-Length: 244
 Content:
 {
  "error": {
    "code": "invalidRequest",
    "message": "Name from path does not match name from body",
    "innerError": {
      "request-id": "4e416429-1c80-40d8-b559-fa90213c6197",
      "date": "2020-03-11T17:32:08"
    }
  }
}
 Duration: 00:00:00.0001839