邮递员:将给定的header添加到给定的collection或collection-level中的所有请求header

Postman: add a given header to all requests in the given collection or collection-level header

我的问题: 邮递员:将给定的header添加到给定的collection或collection-level中的所有请求header。

详情(如截图): 我在 collection 中有“x-apikey”header 和一堆请求,但没有这个特定的 header。 如何避免为每个请求一个一个地添加 header 的手动工作? 请问有人有现成的解决方案吗?

我是如何发现问题的: 导入的 OpenAPI 规范 & 它不包含所需的 header。因此,需要添加到每个请求。

您应该可以在 Pre-request Scripts 的 Collection 水平上做到这一点。

pm.request.headers.add({key: 'x-apikey', value: 'token_value' })