How can we send environment variable value while running through newman

I want to send the environment variable value while running through newman
like env=dev, is this possible ?

--env-var "foo=bar"

you can goto the npm page to see all supported command line options , for passing a variable foo with value bar , you can use --env-var flag as shown


@SaravananSeenivasan Yes it should work as @praveendvd stated :blush:

Please feel free to check out the similar post discussed in the forum :partying_face:

1 Like

Thanks for the help @praveendvd
is there anyway we can use the collection variable in same way, i did not find anything for collection variable only global and environment variables are allowed.

Yes it worked, thanks @bpricilla

1 Like

@praveendvd @bpricilla - any solution for this ?

That’s not possible as of now , when ever you are accessing variables in script section use pm.variables.get() instead of specifying the scope so that the value will be resolved according to precedence

Eg if only collection variable is available then that is retrieved , if both collection and environment with same name exists then value will be from environment.

As lower scope has higher precedence