Reputation: 5694
Currently, it is possible to set and get variables from the global
and environment
scope, as well as the generic variable
in a pre-request script. However, the documentation is not clear if it is possible to programmaticaly set collection
scoped variables.
For example
pm.environment.set("timestamp", timestamp); //acceptable
pm.global.set("signature", hash); //acceptable
pm.variable.set("signature", hash); //acceptable
pm.collection.set("signature", hash); //not possible?
Is this possible?
Upvotes: 24
Views: 18141
Reputation: 25921
You can only currently set these manually at the Collection level but you can reference these using the pm.variables.get('var_name')
syntax.
EDIT:
Postman now allows you to use:
pm.collectionVariables.set('var_name', 'var_value')
and pm.collectionVariables.get('var_name')
to interact with the Variables at the Collection level.
https://stackoverflow.com/a/58325002/6028443
Upvotes: 28