How can I use Postman Collection Variables?

1.6k Views Asked by At

When I add environment variables I can use them in my post body with {{varName}}. But this does not work for collection variables (Collection > edit > Variables tab)

Postman collection variables

With the settings as shown above, if I add {{firstName}} to my body it does not work. How can I access these collection variables in my posts?

Currently if I try to post postman will just hang for a while then give this error

Error: Script execution timed out.↵    at 
ContextifyScript.Script.runInContext (vm.js:53:29)

If I use an environment variable or just type in a value it works fine.

2

There are 2 best solutions below

0
On BEST ANSWER

It turns out {{varName}} does work. The problem was in my pre-request script. The API I was connecting to requires a checksum on the body so it pre-processes the variables in the body, but it was not setup to handle collection variables. This was causing postman to fail. User error.

0
On

Also, you need to make sure to save the request to the belonging collection before you can use it!