Open In App

How to create and use global variables in Postman?

Postman is an API(application programming interface) development tool that helps to build, test and modify APIs. It can make various types of HTTP requests(GET, POST, PUT, PATCH), save environments for later use, and convert the API to code for various languages(like JavaScript, and Python). In this article, we will learn How do you create and use global variables in Postman.

Prerequisites:

Steps to Create and Use Global Variables in Postman:

Step 1: After downloading and installing the Postman, open the software. Add a new Collection and give it a name like “GFG”.



Step 2: Select the environment quick look icon Environment quick look icon in the workbench as shown. Next to Globals , select Edit (or Add if no variables have been added yet) .

Step 3: Add a variable named geek and give it an initial value of GeeksforGeeks as shown below



Step 4: Select Save icon Save, then close the environment tab

Step 5: When you hover, on the name of your collection, 3 dots will appear. Click on those 3 dots, and then click on “Add new request”

Step 6: Now You can simply paste the API in the space provided and you can call the global variable by {{geek}} , then click on Send. Output will be shown in the body with the status code.

Example: In this example, we will create a global variable, id with a initial value=1. We will call API like:

https://jsonplaceholder.typicode.com/posts/?userId={{id}}

Output:

Article Tags :