【问题标题】:How to add headers in the curl request example of the postman API documentpostman API文档的curl请求示例中如何添加headers
【发布时间】:2021-10-17 01:05:48
【问题描述】:

如何将给定的标头添加到邮递员 api 文档中的 api 请求示例。 我在邮递员的标题中使用 'Content-Type': 'application/json' 来测试我的 api 请求。但是,从我的 api 集合生成邮递员文档后,curl 请求示例是:

curl --location --request POST 'http://domain/endpoint' \
--data-raw '{"key1": "value1",
"key2": value2}'

我想将 --header 'Content-Type: application/json' 添加到文档中的 curl 请求示例中。 请求应该是:

curl --location --request POST 'http://domain/endpoint' \
--header 'Content-Type: application/json' \
--data-raw '{"key1": "value1",
"key2": value2}'

我在此链接中发现有可能: https://www.postman.com/postman/workspace/postman-team-collections/documentation/1372588-81512aa8-f91a-4bcd-a53a-6037780c730e 请参阅文档中的图片: enter image description here

我尝试了许多可能的选项,从预脚本到收集没有结果的通用标头,生成后无法在文档内编辑 curl 请求。

【问题讨论】:

标签: api curl postman postman-collection-runner api-doc


【解决方案1】:

出现问题是因为我没有真正在邮递员中手动设置内容类型标头。 我在 Content-Type 中看到的标题位于邮递员标题的隐藏部分,因此由邮递员自动设置。

【讨论】:

    猜你喜欢
    • 2017-07-23
    • 1970-01-01
    • 1970-01-01
    • 2020-05-31
    • 2018-01-30
    • 2021-04-23
    • 2017-12-01
    • 2021-04-25
    • 2019-11-25
    相关资源
    最近更新 更多