【问题标题】:How can I convert this cURL request that send a file to an API into a PostMan request?如何将这个将文件发送到 API 的 cURL 请求转换为 PostMan 请求?
【发布时间】:2020-05-31 20:41:06
【问题描述】:

我有以下问题。我可以通过 cURL 执行以下请求:

curl -F file=@"C:\\FE_example.xlsx" http://localhost:8080/api/comp_vibr_and_temp_tab

而且效果很好。如您所见,我将文件附加到 POST 请求(文件的预期格式为 MultiPart)。此 API 返回的值为 JSON。

使用之前的 cURL 命令可以正常工作,但尝试通过 PostMan 执行相同的请求时出现错误。

在 PostMan 中,我将文件设置到 Body 部分。进入我设置的Header部分:

Content-Type: multipart/form-data

尝试执行请求时,我收到以下错误消息:

{
    "timestamp": 1581890120091,
    "status": 400,
    "error": "Bad Request",
    "exception": "org.springframework.web.multipart.support.MissingServletRequestPartException",
    "message": "Required request part 'file' is not present",
    "path": "/api/comp_vibr_and_temp_tab"
}

为什么?怎么了?如何将我的 cURL 请求转换为正确的 PostMan 请求?

【问题讨论】:

    标签: http curl postman


    【解决方案1】:

    您可以尝试以上步骤来解决您的问题。

    【讨论】:

      猜你喜欢
      • 2018-01-30
      • 1970-01-01
      • 1970-01-01
      • 2020-02-26
      • 2019-06-28
      • 1970-01-01
      • 2022-01-08
      • 2018-04-16
      • 2021-02-06
      相关资源
      最近更新 更多