我一直在努力让上传文件发布。我得到的是404找不到的错误,这没有帮助。我正在使用C#HttpWebRequest。当我在fiddler中捕获请求时,这就是它的样子。
-
POST https://api.box.com/2.0/files/content HTTP/1.1
Authorization: BoxAuth api_key=APK_KEY&auth_token=AUTH_TOKEN
Content-Type: multipart/form-data; boundary=----------------------------8cfa73fa0212bf1
Host: api.box.com
Content-Length: 198082
------------------------------8cfa73fa0212bf1
------------------------------8cfa73fa0212bf1
Content-Disposition: form-data; name="folder_id";
532901558
------------------------------8cfa73fa0212bf1
------------------------------8cfa73fa0212bf1
Content-Disposition: form-data; name="filename"; filename="Pasha.pdf"
Content-Type: application/pdf
%PDF-1.5
%����
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(en-CA) /StructTreeRoot 29 0 R/MarkInfo<</Marked true>>>>
endobj
2 0 obj
// rest of file data goes here ... too long to post
------------------------------8cfa73fa0212bf1
答案 0 :(得分:0)
这是请求的示例,您需要向box.com发送什么
POST https://api.box.com/2.0/files/content HTTP/1.1
Authorization: BoxAuth api_key={key}&auth_token={token}
Content-Type: multipart/form-data; boundary="d174f29b-6def-47db-8519-3da38b21b398"
Host: api.box.com
Content-Length: 314
Expect: 100-continue
--d174f29b-6def-47db-8519-3da38b21b398
Content-Disposition: form-data; filename="hello.txt"; name="filename"
Content-Type: application/octet-stream
{Bytes}
--d174f29b-6def-47db-8519-3da38b21b398
Content-Disposition: form-data; name="folder_id"
0
--d174f29b-6def-47db-8519-3da38b21b398--