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

前端 未结 7 2079
春和景丽
春和景丽 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:00

    Looks like pm.request.headers.add() doesn't currently update the request being sent. It's been marked as a feature request: https://github.com/postmanlabs/postman-app-support/issues/4631

    You might already know that you can create pre-set headers (from the Presets dropdown) to make setting your headers a little bit easier. And there's a couple options under Settings to include specific headers. But these suggestions don't automatically add a header to every request in the whole collection like you're asking about.

    UPDATE: Postman added support for this in Postman App (v7.0.9).

提交回复
热议问题