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

Created on 10 Mar 2020  路  14Comments  路  Source: OneDrive/onedrive-api-docs

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!

Needs Needs

Most helpful comment

@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.

All 14 comments

Thank you for your contribution to OneDrive API Docs. We will be triaging your incoming issue as soon as possible.

Thanks for your feedback. Could you provide more information about the request that failed? Such as a request ID or correlation ID? (I'll tag w/ a label that our helpful bot will fill in w/ details, thanks!)

Thanks for your feedback; however, we need more information to understand the issue further. If you have not provided the following information, could you please provide the following?

Could you please provide the following response headers:
- Date (in UTC, please)
- request-id
- SPRequestGuid (for requests made to OneDrive for Business)
Please provide as recent values as possible.

Could you please describe the steps to reproduce the bug in sufficient detail for another person to be able to reproduce it?

Could you please provide sample requests and responses that illustrate the issue that you are encountering?

Could you please describe the behavior you expected to occur when performing the action?

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

Any updates? It seems I am following official documentation correctly.

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

Request:

 POST /v1.0/drives/b!r.....DQ/items/01QW.....Z4k/createUploadSession https/1.1
 Host: https://graph.microsoft.com
 Authorization: Bearer <access-token>
 Content-Type: application/json; charset=utf-8
 Content:
 {"Item":{"name":"testfile.txt"}}

Response:
```
{'error': {'code': 'invalidRequest',
'innerError': {'date': '2020-03-23T21:31:17',
'request-id': '0e91e839-7d88-4f4f-ae38-94b5edcd54ab'},
'message': 'Name from path does not match name from body'}}
````

I'm using the python requests library to make the POST request, but the behavior is the same.

@msft-github-bot, @chackman, @Microsoft are your services so buggy and just don't work? GSuite seems a bit trickier, but everything works like a charm...

@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!

@agat366 : thx for correct url!

Please reopen this issue and don't close it until the documentation is fixed.
This product should not be considered working until a user can use it when following the documentation.

Maybe change the title to mention that this is a documentation problem.

Also this is not the only place where the documentation is wrong or incomplete.

Ran into the same issue. Please reopen and update the documentation.

I have opened a new issue, #1319, which includes this problem as well as another problem where the documentation for the body of the request does not match what actually works. The new issue has been tagged and added to the backlog.

createUploadSession when sending a (new) file to a shared folder (400 Bad Request error) #1319

Was this page helpful?
0 / 5 - 0 ratings

Related issues

audiorecorder picture audiorecorder  路  5Comments

indigane picture indigane  路  9Comments

kverhoef picture kverhoef  路  3Comments

neunygph picture neunygph  路  9Comments

rkulow picture rkulow  路  7Comments