I want to automatically add a header to every request in my whole collection using this pre-request script:
pm.request.headers.add({
\'key\': \"myvar\",
I think may be you can try this way :
// Add or update an existing header
pm.request.headers.upsert({
'key': "myvar",
'value': pm.environment.get("myvar")
});
This was updated in Postman App (v7.0.9). For more reference you can refer to : https://github.com/postmanlabs/postman-app-support/issues/1947