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

前端 未结 7 2080
春和景丽
春和景丽 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 08:04

    As of Postman v7.0.9, this is now possible by adding a Pre-request Script on a collection.

    To do this, go to your collection, right-click it, select Edit, and go to the Pre-request Scripts tab, where you can add your snippet, i.e.:

    pm.request.headers.add({
      key: 'X-HEADER-TEST',
      value: '1'
    });
    
    0 讨论(0)
提交回复
热议问题