Setting headers for entire collection/folder

As of 7.0.9 - You should be able to now do this in your Pre-request Scripts.

You can use the following syntax:

pm.request.headers.add({key: 'header_name', value: 'header_value' })

pm.request.headers.upsert({key: 'header_name', value: 'header_value' })

pm.request.headers.remove('header_name')

EDIT: Fork this collection to see how it works directly in Postman:
https://www.postman.com/postman/workspace/postman-answers/collection/9215231-ef055751-7385-45b4-a6f9-91bbd1c47fa5?ctx=documentation

8 Likes