我正在Windows上执行以下curl命令。该命令已执行但curl不会附加文件正文。它只写头:
curl.exe -H "Authorization: Bearer very-secret-stuff" -F file=@E:/almostEmpty.txt --verbose https://to-this-address
已发送请求:
POST /api/rest/v5/transientDocuments HTTP/1.1
Host: api.eu1.echosign.com
User-Agent: curl/7.56.1
Accept: */*
Authorization: Bearer very-secret-stuff
Content-Length: 214
Content-Type: multipart/form-data; boundary=------------------------e84a74f3e81c968e
***Nothing here. The file body is actually missing***
收到回复:
HTTP/1.1 400 Bad Request
Date: Wed, 08 Nov 2017 12:28:00 GMT
Server: Apache
x-request-id: 613647cc-c04b-49d7-8b86-62fc65841a8a
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
Content-Length: 61
Strict-Transport-Security: max-age=31536000;
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Robots-Tag: none
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Connection: close
Content-Type: application/json;charset=UTF-8
{"code":"NO_FILE_CONTENT","message":"Must provide file body"}
Closing connection 0
TLSv1.2 (OUT), TLS alert, Client hello (1):
答案 0 :(得分:0)
根据他们的documentation,文档的参数为File
,而不是file
。
尝试更改cURL命令以使用:
-F File=@E:/almostEmpty.txt
另请注意,--verbose
不会在控制台上显示文件内容,只显示标题和响应标头。您的文件正在发送,只是表单参数名称错误。
答案 1 :(得分:0)
FWIW: ContentType 不带连字符
正如Drew在上方的“文件”帖子字段中使用大写字母F所说的