Mashape多部分表单POST请求

时间:2015-09-28 16:20:21

标签: rest post curl multipartform-data mashape

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

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脚本中运行这个精确的卷曲时,一切都运行顺畅,但是当我尝试通过mashape运行它时,它表示400 Bad Request500 Internal Server Error

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

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

0 个答案:

没有答案
相关问题