nicholmikey
nicholmikey

Reputation: 358

How can I use Postman Collection Variables?

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.

Upvotes: 1

Views: 1922

Answers (2)

fahu
fahu

Reputation: 1531

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

Upvotes: 2

nicholmikey
nicholmikey

Reputation: 358

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.

Upvotes: 0

Related Questions