【发布时间】: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 请求。
【问题讨论】:
-
learning.postman.com/docs/publishing-your-api/… 即使在官方文档中也没有提及该主题
-
--request POST在使用--data-raw时也应该被删除。尤其是结合--location... -
是的,但它可以使用。最大的问题仍然是 curl 请求中缺少的标头
-
只有在你幸运的时候才能使用它:daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x
标签: api curl postman postman-collection-runner api-doc