How to Define a Variable in Postman?

For better understanding we are going to use this demo API https://reqres.in/api you can replace this with your API to perform testing with variables.

To define variables in Postman follow the below steps.

Step 1: Type or paste your API in the request tab.

Step 2: Select the type of your request.

Step 3: Select the data you want to store in the variable and click on set as a variable.

Step 4: Click on set as a new variable.

Step 5: Enter your variable’s name and select the variable’s scope. Here we will select global.

Step 6: Then click on the set variable.

Step 7: Now you will see your data is replaced with your variable inside {}. Now click on send to test your API and fetch the data.

How to Create Variables in Postman with Different Scopes

If you use Postman for testing your APIs and want to learn how to declare variables in it then this article is going to be helpful for you. In this article, you will learn how you can declare variables in Postman step by step. You will also learn about the various scopes of variables, their types, and their use cases in different scenarios. So deep dive into this article and master the variables in Postman.

Similar Reads

Introduction to Variables in Postman

Suppose you are using the same base_url for testing various end points of your API. Then you can define that base URL in a variable and then make requests by just changing the end points of your API. Follow the example below for a better understanding....

Why Should We Use Variables?

We must use variables in Postman for the following reasons:...

How to Define a Variable in Postman?

For better understanding we are going to use this demo API https://reqres.in/api you can replace this with your API to perform testing with variables....

Scope of Variables in Postman

Scope defines the context in which a variable is defined and determines where the variable can be accessed. In Postman variable scopes play a crucial role in managing and controlling the visibility and accessibility of the variables throughout the workspace. There are several types of scopes in Postman that provide accessibility according to your needs....

Type of Variables

There are generally two types of variables supported in Postman default and secret....

Conclusion

In this article, we have learned the importance of variables in postman. We learnt how we can declare variables of different types. We understood the concepts of scopes of variables and learned when to use variables with a suitable scope. We also learned how to create secret variables to protect our sensitive data. We hope that this article has helped you to understand the variables in Postman....

FAQ’s

1. Can we change the value of a global variable during the runtime?...