# How can we send environment variable value while running through newman

**URL:** <https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132>\
**Category:** Help Hub\
**Tags:** newman-project, variables, collections, setenvironmentvariab\
**Created:** [March 31, 2021, 12:28pm UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132 "2021-03-31T12:28:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SaravananSeenivasan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/saravananseenivasan/32/8301_2.png) [@SaravananSeenivasan](https://community.postman.com/u/SaravananSeenivasan)\
**Post date:** [March 31, 2021, 12:28pm UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/1 "2021-03-31T12:28:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [March 31, 2021, 8:28pm UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/2 "2021-03-31T20:28:13Z")

</div>

> **[newman](https://www.npmjs.com/package/newman)**
>
> Command-line companion utility for Postman

`--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

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [March 31, 2021, 11:47pm UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/3 "2021-03-31T23:47:48Z")

</div>

@SaravananSeenivasan Yes it should work as @praveendvd stated 😊

Please feel free to check out the similar [post](https://community.postman.com/t/newman-modifying-env-var-parameter/13685/2) discussed in the forum 🥳

---

<div class="post-metadata">

**Author:** ![SaravananSeenivasan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/saravananseenivasan/32/8301_2.png) [@SaravananSeenivasan](https://community.postman.com/u/SaravananSeenivasan)\
**Post date:** [April 1, 2021, 2:01am UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/4 "2021-04-01T02:01:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SaravananSeenivasan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/saravananseenivasan/32/8301_2.png) [@SaravananSeenivasan](https://community.postman.com/u/SaravananSeenivasan)\
**Post date:** [April 1, 2021, 2:01am UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/5 "2021-04-01T02:01:46Z")

</div>

Yes it worked, thanks @bpricilla

---

<div class="post-metadata">

**Author:** ![sseenivasan89](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sseenivasan89/32/8350_2.png) [@sseenivasan89](https://community.postman.com/u/sseenivasan89)\
**Post date:** [April 4, 2021, 4:00am UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/6 "2021-04-04T04:00:13Z")

</div>

@praveendvd @bpricilla - any solution for this ?

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [April 4, 2021, 6:59am UTC](https://community.postman.com/t/how-can-we-send-environment-variable-value-while-running-through-newman/22132/7 "2021-04-04T06:59:19Z")

</div>

> <https://github.com/postmanlabs/newman/issues/2192>
>
> Allow the specification of collection variables via the command line, just like it currently works for the environment and global variables.
> \--collection-var...

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
