Generate header based on body for a collection of requests

Hi everyone!

I have a service that checks if a dynamically generated header has a certain value.

For sake of simplicity let’s suppose this header is the concatenation of URL and body. It should be feasible to do so for a single request using variables.

How can I extend this behavior to all the requests of a collection?

Hey @flight-architect-935 :wave: Welcome to the Postman Community :tada:

If I understand your query correctly, you want to apply the same set of script for each request in a collection, is that correct?
If so, you can add pre-request script for a collection as below to add pm.request.headers.add() method to add a custom header to each request:

Hope this helps! Let me know if you have further questions :smiley:

2 Likes

Thank you! That’s indeed what I needed :slight_smile:

1 Like