Helpful Tip: Uploading user pictures requires multipart request


POST /users/{userId}/picture is documented as taking one piece of request data “pic_file” which is of type “file” and “must be a jpg/jpeg” but provides no other documentation. The test request shows an example with the Content-Type application/json, but attempting to use this will return a 400 Bad Request error with the message “Current request is not a multipart request”.

Instead, I found success piecing together random comments on the internet and using “Content-Type: multipart/form-data; boundary=$boundary” (where $boundary is the unique, semi-random string that does not occur within the file contents). In place of a JSON request body, the multipart/form-data request body looks like this:

Content-Disposition: form-data; name="pic_file"; filename="$filename"
Content-Type: image/jpeg


It’s also important to note that the line endings are \r\n between the lines (otherwise you will receive a 500 Internal Server Error).

Hopefully that will save others the time it cost me.


Thanks for giving a tip to our community! We are going through our API docs now and beefing them up so I will add this example to the list of improvements.