I need to be able to do something like that … is it possible?
var variable = “storm” //I get this value from a previous request
var jsonData = pm.response.json();
pm.globals.set (“type”, jsonData.rain.(pm.environment.get (“variable”));
Hi there @pablovok - looks like you want to parse a response and set a global variable based on an environment variable from the previous request.
// if you set the environment variable in the previous request like
pm.environment.set("variable", "storm")
// then this would work
var variable = pm.environment.get("variable");
var jsonData = pm.response.json();
pm.globals.set("type", jsonData.rain.variable);
// and if `jsonData.rain.variable` is an object, remember to encode it properly, like
pm.globals.set("type", JSON.stringify(jsonData.rain.variable));
Thanks @jetison or your time and help.
I want to capture a value from the response, but build the path based on the values I capture from other responses.
Try what you mentioned above, but it doesn’t work for me.
The variable is not recognized as part of the path.