Introduction
In this step-by-step article series, next we are going to learn about the Preset Headers features of the postman. Before going to learn about the preset headers, please read the previous article of this series for a better understanding:
This article covers the following topics:
- Preset headers
- Adding preset headers
- Using preset headers
Preset Headers
When you want to interact with an API, some headers are required whenever you place a request. Headers include username, password, API-key, Authorization, etc. but when you work with the application it's automatically set and sends the request. In case of directly hitting the API, you are required to pass those headers every time you need to make a request.
In postman when you make a new request you need to fill all the headers again, to save your time Presets or Preset Headers comes into the picture to preserve the headers setting to use in future requests.
The presets are located under the headers section when you are requesting the above screenshot.
Adding preset headers
Let's see how to add the preset headers, using the below steps:
Step 1
Open the postman, create a new request and click on headers, select 'Presets' dropdown 'Manage Presets' value as below:
Step 2
Once you click on 'Manage Presets', it will open the pop-up as below:
In this pop-up, you can manage your group of preset headers such as add, update, or delete the group. The group contains the header key-value pairs.
Step 3
Next, click on the 'Add' button, and it opens another pop-up to create the preset header group as below:
The contains the Preset Header Name, Key, Value, Description to be filled, and Bulk Edit functionality.
Step 4
Next, fill in the required details for the group of preset headers and click on the 'Add' button as below:
Step 5
Once you clicked on the 'Add' button it adds that group and you will see the list of groups below:
In the pop-up after the 'Add' button, you will see the recently added 'GET-Headers' group. Here you can manage the groups such as 'Add', 'Update', and 'Delete'.
For update functionality, just click on the group name and you will see a pop-up as below:
For delete functionality, just click on the delete icon and it will give you a warning message before deleting that group as below:
Hope you understand how to add or manage the preset header group.
Using preset headers
In the previous section we learned how to add the preset group, let's see how to use it in the request as below steps:
Step 1
Create a new request, go to the headers tab and click on the 'Presets' dropdown as below:
In the above screenshot, you can see the recently added group is there next to 'Manage Presets' which is 'GET-Headers'.
Step 2
Next, click on the recently added group which is 'GET-Headers' and it adds to the headers as below:
In the headers tab, you can see the headers added 'API-Key' and 'User-Name' from the group we have created which is 'GET-Headers'. It's not like we have selected it from presets so it's not editable, we can update that value here.
Stay tuned to learn new things about Postman….
Conclusion
In this article, we learned about Presets, headers, and how to add and use them in a request. If you have any suggestions or queries regarding this article, please contact me.
"Learn It, Share it."
Read Next - Learn Postman Step By Step - Import via cURL, HAR