Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postman pm set environment variable

I will get the JWT token as response i need to set that JWT token as environment variable in postman this is my code

pm.test("access_token is working", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.access_token).to.exist;
});

pm.environment.set("jwt_token", pm.test);

and when ever the JWT token changes the postman environment variable should set as that new value

like image 212
Jeevan Mahesha Avatar asked Aug 23 '26 23:08

Jeevan Mahesha


1 Answers

This would be all you need to set the token:

pm.environment.set("jwt_token", pm.response.json().access_token)

Ensure that you have an environment created and selected in the drop down, in the top right of the app before making the request.

like image 136
Danny Dainton Avatar answered Aug 26 '26 12:08

Danny Dainton