I am a bit puzzled about how the environment variables are preserved between the monitor runs. So, I have a collection that contains a chain of requests, collects the JSON responses and stores some of the obtained IDs as environment variables at the end of the “Tests” stage of the requests:
Passing the environment variables works just fine within a single collection run performed by a Postman monitor. However, when I try to get environment variable value from the last run, I get the initial value stored into the environment configuration, just as every monitor run would start from scratch. That makes the precautions “if it failed last time, cancel last flow before continue any further” useless.
Am I missing something obvious here? Could that be a side effect of the fact that the environments are shared within the team?
To pass updated environment variables across monitor runs, you can add another call to your collection to update the environment in use. In other words, submit a PUT request using the Postman API to update the environment.
Hi,
I notice that you said env vars are persisted (if the setting is on) across collection runs. I am trying to do that to persist JWT Tokens in env vars. Not happening.
I set the env var as:
pm.environment.set(‘accessTokenLearner’, jsonData.accessToken);
it works within the collection run but not across it.