尝试上传文件时使用HTTP 500 [英] HTTP 500 when trying to upload a file

查看:141
本文介绍了尝试上传文件时使用HTTP 500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的Box上传POST,可将文件上传到特定文件夹:

Here is my Box upload POST to upload a file into 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 get this response, that doesn't help me to understand what the problem is:

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

EMPTY MESSAGE

任何人都可以告诉我在导致HTTP 500的请求中我做错了吗,请?

Can anyone tell me what I'm doing wrong in my request to cause the HTTP 500, please?

推荐答案

您的分段请求格式似乎不正确。最简单的方法是使用SDK 或查找可以为该请求构建多部分请求的库

It looks like your multipart request isn't properly formatted. The easiest way to do this is to use an SDK or find a library that can build a multipart request for you.

如果您真的想手动构建请求,那么下面是一个上传请求的示例:

If you really want to build the request manually, then here's an example of what an upload 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--

这篇关于尝试上传文件时使用HTTP 500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆