HTTP 500 when trying to download a file

Here is my box uploading a POST to upload a file to a specific folder:

POST /api/2.0/files/content HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Accept: application/json
User-Agent: SOASoftware/7-HttpCore/4
Transfer-Encoding: chunked
Content-Type: multipart/form-data
Host: upload.box.com
Connection: Keep-Alive

attributes='{"name":"lead.txt", "parent":{"id":"2890481033"}}'&file=C:\SOA\Software\sm70\instances\nd\leads.txt
-----------------------------9051914041544843365972754266
<file-data>
-----------------------------9051914041544843365972754266

      

but I am getting this answer which does not help me understand what the problem is:

HTTP/1.1 500
Age: 0
Date: Fri, 02 Jan 2015 09:06:09 GMT
Connection: close

EMPTY MESSAGE

      

Can anyone tell me what I am doing wrong in my request to invoke HTTP 500 please?

0


source to share


1 answer


It looks like your multipage request is not formatted properly. The easiest way to do this is to use the SDK, or find a library that can build a multipart query for you.

If you really want to create a request manually, here's an example of what a download request should look like:



POST https://upload.box.com/api/2.0/files/content HTTP/1.1
Host: upload.box.com
Authorization: Bearer ACCESS_TOKEN
Content-Length: 346
Content-Type: multipart/form-data; boundary=------------------------393329c2f2238ab4

--------------------------393329c2f2238ab4
Content-Disposition: form-data; name="attributes"

{"name":"my-file.txt", "parent":{"id":"0"}}
--------------------------393329c2f2238ab4
Content-Disposition: form-data; name="file"; filename="my-file.txt"
Content-Type: application/octet-stream

<file-data>

--------------------------393329c2f2238ab4--

      

0


source







All Articles