How to set Environment Variables in Postman?

How to set Environment Variables in Postman?

Setting Environment Variable in Postman avoid manually setting the variable values for subsequent API Calls.
 
1. pm.environment.set() can be used to set Environment Variable in Postman. Code should be used under Tests tab.
 
Sample Code:
let jsonData = JSON.parse( responseBody );
pm.environment.set(“loginId”, jsonData.login);
pm.environment.set(“URL”, jsonData.url);
pm.environment.set(“nodeId”, jsonData.node_id);

2. Once the request is sent. We can check the variable values in the Environment.

Leave a Reply