# Settingup pm.sendRequest() as env variable

**URL:** <https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694>\
**Category:** Help Hub\
**Tags:** environments, pmsendrequest\
**Created:** [June 27, 2024, 6:24am UTC](https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694 "2024-06-27T06:24:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacecraft-technol17](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@spacecraft-technol17](https://community.postman.com/u/spacecraft-technol17)\
**Post date:** [June 27, 2024, 6:24am UTC](https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694/1 "2024-06-27T06:24:51Z")

</div>

I am setting up few requests which need to be executed before certain requests of collection at pre-request script via pm.sendRequest() method.

My need is to keep entire pm.sendRequest() as environment variable and will call it in required pre-request tab by getting its variable name as pm.environment.get(“variablename”)… Also,i want to update json key value after getting it from environment.

Any help on this…

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [June 27, 2024, 11:01am UTC](https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694/2 "2024-06-27T11:01:20Z")

</div>

Have a look at the following article on Stack Overflow.

[javascript - How to Write Global Functions in Postman - Stack Overflow](https://stackoverflow.com/questions/45673961/how-to-write-global-functions-in-postman)

There are examples of using Environment variables with EVAL that should give you a starting point.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [July 1, 2024, 7:39am UTC](https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694/3 "2024-07-01T07:39:04Z")

</div>

Closed on July 1, 2024, 7:39am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
