Optimism
Optimism

Reputation: 217

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

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

Details (like screenshots): I have “x-apikey” header & a bunch of requests in the collection without this specific header. How can I avoid manual work of adding header one by one to each request? Anyone has an existing solution, please?

How I found the problem: Imported OpenAPI spec & it does not contain the needed header. Hence, need to add to each request.

Upvotes: 7

Views: 7786

Answers (1)

Danny Dainton
Danny Dainton

Reputation: 25851

You should be able to do this in your Pre-request Scripts at the Collection level.

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

Upvotes: 21

Related Questions