Variables in Postman

What is a variable? This is the basic question to learn when you start programming. I am not going to dive deep into the programming concepts. Let me explain the variables used in Postman.

What is a Variable in Postman?
  • A data unit, that stores a value and it is dynamic based on the data type we use. 
  • Should be written as Key: Value pair (Example: name= "Test"; num=1;)
  • Provides the facility to access the value without manual effort every time.
There are 5 different scopes of variables used in Postman.
  1. Global Variables
  2. Environment Variables
  3. Collection Variables
  4. Data Variables
  5. Local Variables
These variable scopes are specially designed to refer to values in the Postman tool.

Global Variable:
        When the variable is assigned globally, it has all the privileges of accessing anywhere in the workspace such as the Environment, Collection.

Environment Variable:
        It is limited within the specific environment where you can access data between collections.

Collection Variable:
        The scope of this variable can be accessible to any of the requests inside a collection.

Data Variable:
        These values come from CSV or JSON files when one adds a file while running the collection. It has the data and is associated with the particular request with Collection Runner and Newman.

Local Variable:
        As the name suggests, it is accessible only to the particular request, and when one wants to use the same variable already declared in the environment or collection, the local variable replaces all the values from different scopes and can be used temporarily for this request.

To suggest, it is always better to use different variable names to avoid overriding of the values.






Comments

Popular posts from this blog

How to Install Jenkins

HTTP Payloads