DEV Community

Discussion on: Which programming language/environment is more “powerful” than people realize?

Collapse
 
itsasine profile image
ItsASine (Kayla) • Edited

Postman

There are multiple ways to scope variables to keep your saved calls dynamic, but also through the tests tab you can basically run any JS you want.

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

var jsonData = pm.response.json();

pm.environment.set("Authorization", jsonData.token_type + ' ' + jsonData.id_token);

So I can test my responses (good practice!) but also take the response from my OAuth call and automagically set it to my environment variables.

Then, every subsequent actual call just needs to have a header of Authorization: {{Authorization}}