Scheduled maintenance planned for September 30, 2023.

Unable to Upload Files using API and Curl

New post



  • Official comment

    I am so sorry, it seems we had a mistake in our cURL samples for uploads.

    The correct endpoint for uploads is on a different domain. I've updated the samples

    curl -i -X POST \
    -H 'Authorization: Bearer <TOKEN>' \
    -H "Content-Type: multipart/form-data" \
    -F attributes='{"name":"file.txt", "parent":{"id":"1234"}}' \
    -F file=@file.txt

    As for the issue you encounter with double/single quotes: behaviour of cURL between Linux/Mac/Windows is slightly different. You can choose to either use single quotes on the outside, and then use double quotes in the JSON, or use double quotes around the whole string and then use escaped double quotes in the JSON. For example:

    -F attributes="{\"name\":\"file.txt\", \"parent\":{\"id\":\"1234\"}}"

    I also recommend adding -i to your API calls so you can see the headers returned by the API, which is useful when the API returns an error.


    Comment actions Permalink
  • Box User

    This worked!! Please update the official documentation as I spent 3 days trying to get it to work. Thank you again!

    Comment actions Permalink
  • cbetta

    Already fixed. So sorry about that!

    Comment actions Permalink
  • RTSBox

    Hi CBetta the problem still exists and while trying to implement the curl that way we get this response 'API Upload did not contain a file part.' Please responsd as soon as possible. Thanks.

    Comment actions Permalink
  • LinThaw

    Please share possible reasons and solutions for [API Upload did not contain a file part.] error.

    Comment actions Permalink

Please sign in to leave a comment.