Pre-request scripts not working for me

I added some JavaScript in the pre-request script tab for a collection to add some headers but none of them are getting executed.
Here is the text I added:
pm.request.headers.add({key: “Authorization”, value: “Basic xxxxxxxxxx” })

here, xxxx is the key value.

I looked at the console logs and this header is not showing up there, I also added a console.log(“Hello”) that is also not showing up in the logs.

Would really appreciate some help on this.

Hi @ritvik-saras

Not really sure why it doesn’t work for you, it works for me;


If it’s still not working could you screenshot what you are sending / seeing etc?

is this at a collection level?

This is how my request headers are

That was tested at both collection level and HTTP request level, both work.

Here is the output from setting at the collection level and running the collection runner.

Note that, if you set it at the collection level, if you run the HTTP request individually, you will not trigger the pre-req script at the collection level, you need to run via the collection runner for that you happen.

Hope that helps.