0

我的 API 中有一个 POST 方法,它使用多部分编码的表单数据。我已经设置了正确的标题和数据设置,以便 mashape Web 界面生成以下 curl:

curl -X POST --include 'https://sslavov-text-analytics-v1.p.mashape.com/news' \
  -H 'Authorization: Basic ***********' \
  -H 'X-Mashape-Key: ************' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@sample.docx' \
  -F 'meta={"documentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"};type=application/json'

基本上我正在尝试上传一个带有简单文本段落的文件进行处理。奇怪的是,当我在 bash 脚本中运行这个精确的 curl 时,一切都很顺利,但是当我尝试通过 mashape 运行它时,它会显示400 Bad Request或者500 Internal Server Error

在我的特定情况下,当我没有传递正确的表单或标题时会生成这些错误。所以我的问题是: curl 语法是否有错误,还是我应该继续在服务器端查找错误?

编辑:我想出了问题所在。-F 'file=@sample.docx'之前通过了-F 'meta....',这导致了500 Internal Server Error所以现在的问题是:有没有办法专门安排表单字段的顺序(因为 mashape 重新排列了它们)?

4

0 回答 0