Add header to every request in Postman in pre-request script

前端 未结 7 2076
春和景丽
春和景丽 2021-02-05 07:00

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\",
             


        
7条回答
  •  攒了一身酷
    2021-02-05 07:51

    This certainly works. Loose the inverted commas on key and value

    pm.request.headers.add({
        key: "myvar",
        value: pm.environment.get("myvar")    
    });
    

提交回复
热议问题