这是我的Box上传POST,用于将文件上传到特定文件夹:
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
但我得到了这个回复,这无助于我理解问题所在:
HTTP/1.1 500
Age: 0
Date: Fri, 02 Jan 2015 09:06:09 GMT
Connection: close
EMPTY MESSAGE
有人可以告诉我,在我的请求中我做错了什么导致HTTP 500,
答案 0 :(得分:0)
您的多部分请求似乎未正确格式化。最简单的方法是use an SDK或查找可以为您构建多部分请求的库。
如果您真的想手动构建请求,那么这里是一个上传请求应该是什么样子的示例:
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--