Postman Tutorial Part 39 – Header Presets in Postman

What we will learn in this post:-

  1. Introduction to Header Presets
  2. Usage of Header Presets
  3. Creating and using Header Presets
  4. Managing Header Presets

Let’s think of a scenario before we jump to the concept of header presets.

Suppose you need to add multiple headers or a set of headers to each request or different set of groups of headers for different set of requests. You may be thinking of explicitly adding in to each requests. Is it not really boring and irritating and time consuming process?

If we could create different groups of headers which we can call wherever needed, will solve our problems. We have a similar readymade solution in Postman called Header Presets.

Header Presets is a group of headers which stores each header and its value as a key – value pair. You can use it quickly to add groups of headers to the request.

Let’s create a Header Presets:-

When we navigate to “Headers” tab of any request, we see a control called “Presets” as shown below:-

Click on “Presets” control. It will show an option called “Manage Presets” as a dropdown. Click on “Manage Presets“. You will see a dialog box as shown below:-

Click on “Add” button. Give name to Presets and add some headers with value and click on “Add” button.

It will list given header presets name ( “Sample Header Presets” as shown above). You can add multiple header presets like this. You can delete presets by clicking on cross sign as shown below.

You can update presets by clicking on its name.

So we have learnt to create/ Update and Delete header presets. Now time to learn its usage.

How to use created Header Presets:-

Navigate to “Headers” tab of a request and just type the name of Header presets in key text box. I have given name as “Sample Header Presets” so I will start typing character by character. All presets suggestion will be listing in dropdown with prefix as “Header Presets”.

Just click on that name. You will see all headers are added to request as individual at once. Remember it does not add headers as a reference. In programming term, It is call by value not call by reference.

There is another way to add presets. Click on “Presets” control at Header tab. It will show an option called “Manage Presets” and all created presets in dropdown. Select whatever you want to add.

Now you can add, edit , remove headers as we do normally. It will save a lot of time.

Drawbacks of Header Presets:-

As it does not populate headers as reference, it limits advantages of presets. Some drawbacks are given below:-

  1. If you want to update header value in presets, updated value will not be reflected automatically in request where presets were added earlier.
  2. Once you add presets in a request, there is no provision to remove headers of a selected presets.

We can use global or environment variables for key and value in header presets. This solves the problem of managing presets to some extent. Example is shown below:-

#ThanksForReading

Have you tested your Selenium knowledge ? Try below Selenium Quiz:-

Learn Selenium with Quiz

Be master in Selenium-WebDriver

API Testing – Basics

API Testing – Postman

API Testing – Rest Assured

Learn Protractor Step by Step

Frequently Asked Java Programs in Interview

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.
%d bloggers like this: