- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the value of environment variable in Postman?
We can get the value of an Environment variable in Postman at runtime with the help of scripts. This is done with the help of the pm.* function. The script to get the Environment variable can be included either in the Tests or Pre-Request Script tab
To get an Environment variable, the script should be −
pm.environment.get('<name of Environment variable>')
Finally, to get the value of the Environment variable in the Postman console, the script should be −
console.log(pm.environment.get('<name of Environment variable>'))
Let us try to get the value of the Environment variable tutorial.
Step1 − Add the below script to get the value of the Environment variable tutorial and print it in console.
console.log(pm.environment.get('tutorial'))
Step2 − Click on Send to execute a request.
Step3 − After the Response is received, open the Postman Console. It displays postman which is the value set for the Environment variable tutorial.
- Related Articles
- How to get environment variable value using PowerShell?
- What is an Environment Variable in Postman?
- How to Create an Environment in Postman?
- How to Use Environment Variables in Postman?
- How to set a global variable in Postman?
- How to create a Global Variable in Postman?
- How to use Global Variable in Postman Request?
- How to set the GOPATH environment variable on Ubuntu?
- How do we set the Java environment variable in cmd.exe?
- How to set python environment variable PYTHONPATH on Linux?
- How to set python environment variable PYTHONPATH on Mac?
- How to set python environment variable PYTHONPATH on Windows?
- How to get the list of available data frames in R environment?
- How to substitute an environment variable using sed on Linux?
- What is PYTHONPATH environment variable in Python?
