Default preset of headers in Postman

Viewed 3303

When manually testing requests in Postman, is there a way to define some set of default headers to be used for each request (without choosing manually Preset before sending each request)? I.e. is there a way to define a default Preset to be used?

Additionaly when I follow some of the links in the response (by clicking on it) and send a request for this link, the headers from the original request are lost. Is there a way to preserve them automatically?

Thanks in advance

2 Answers

There is no direct way to do this but this can be done via Collection level Pre-request script. Steps-

  1. Create a collection in the postman and put all requests in which you want the common headers.
  2. Edit the postman collection.

enter image description here

  1. Write this in your Pre-request Script section.

var Header = require('postman-collection').Header;
pm.request.headers.add(new Header("foo:foo"))
pm.request.headers.add(new Header("bar:bar"))

Related