【问题标题】:Generate a cURL request from a Postman从 Postman 生成 cURL 请求
【发布时间】:2019-11-25 01:29:37
【问题描述】:

我尝试从 Postman 生成 cURL 请求(使用邮递员的 code 选项)。
由于请求包含输入 pdf 文件,邮递员正在添加某些标头属性。
下面是生成的 curl (几乎相似,出于安全原因更改了一些标头),收到的响应 500, internal Server Error, "Current request is not a multipart request"

  http://localhost:8080/test \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded,multipart/form-data; boundary=--------------------------895926775956600620357522' \
  -H 'Some-Key: abcd' \
  -H 'cache-control: no-cache' \
  -F file=@/C:/path/to/my/file/abc.pdf

【问题讨论】:

    标签: http curl postman multipartform-data


    【解决方案1】:

    如果您想在 Postman 中发送multipart 请求,您只需执行以下操作:

    1. 不要在Header 中指定Content-Type
    2. 在 Postman 的 Body 选项卡中,您应该选择 form-data 并选择 file type

    阅读更多here

    【讨论】:

    • 当我从 Postman 中点击它时,我能够得到响应,生成 cURL 是问题所在。
    猜你喜欢
    • 2016-03-08
    • 1970-01-01
    • 2017-07-23
    • 2020-03-04
    • 2018-01-30
    • 2016-03-18
    • 2018-10-27
    • 1970-01-01
    • 2014-10-11
    相关资源
    最近更新 更多