3

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.

Optimism
  • 167
  • 1
  • 8

1 Answers1

10

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' })
Danny Dainton
  • 23,069
  • 6
  • 67
  • 80