Box API Upload file error: Malformed stream

Get HTTP 400 error when invoking upload file API ( The message says “Malformed stream”, but gives no additional information. Tried the exact payload as specified in this box documentation page ( and run it in Postman and still get the same error.

Request Payload:

POST /api/2.0/files/content HTTP/1.1
Authorization: Bearer [ACCESS_TOKEN]
content-length: 343
content-type: multipart/form-data; boundary=------------------------9fd09388d840fef1

content-disposition: form-data; name="attributes"

{"name":"test.txt", "parent":{"id":"0"}}
content-disposition: form-data; name="file"; filename="test.txt"
content-type: text/plain

Test file text.


Error Response:

    "code": "bad_request",
    "help_url": "",
    "status": 400,
    "message": "Malformed stream",
    "type": "error"

Hello :wave:

In Postman, instead of using the raw tab - I like to use the form-data tab. The collection should automatically have the attributes object ready to fill out and the file selector ready to pick a file.

It also has the code tab which will show to code it is running based on the language you select in the drop down.

When not using Postman, I also suggest using one of our SDKs since it does all the upload logic for you without manually having the create the body since it can be tricky. Is there a reason you cannot use a SDK?

Alex, Box Developer Advocate :avocado:

Thanks Alex! that works.