Setting headers for entire collection/folder

hi guys,

I’m trying to add a header for every request under a folder. The pre-request scripts seem to be my best bet, however, I can’t get it to work with variables. It fails with bad syntax no matter which way I code it and I can’t find any documentation or thread on it.

Essentially, I need to read the values set in the environment variable since the header name and value depends on which environment you’re sending the request from.

So something like this:

pm.request.headers.add( { key: {{headerName}}, value: {{apiKey}} } );

That’s not valid syntax though. So how can I achieve this?

thanks! :slight_smile: