All the examples on learning.getpostman.com site show how to save variables at the global
or environment
level, in order to get a value from one request to another.
For example:
pm.environment.set(variableName:String, variableValue:String)
pm.environment.get(variableName:String)
pm.globals.set(variableName:String, variableValue:String)
pm.globals.get(variableName:String)
respectively.
Is it possible to use Collections instead?
Reading the documentation about the pm.
API doesn't give me much hope.
I am looking for something like this:
pm.collection.set(variableName:String, variableValue:String)
pm.collection.get(variableName:String)
My goal is to be able to run two collections without cross-contamination.
EDIT
Postman evolves. If you read the documentation it is also possible to set the variables in the collection, instead of in the environment. Be aware that if you have variables with the same name set in both places, using {{variablename}}
may not result in the desired outcome.
For example, if a collection variable and an environment variable have
the exact same names, they are still two completely different variables.