# Pre-request substitute environment variables

**URL:** <https://community.postman.com/t/pre-request-substitute-environment-variables/13853>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [July 3, 2020, 2:39am UTC](https://community.postman.com/t/pre-request-substitute-environment-variables/13853 "2020-07-03T02:39:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkevinburton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/rkevinburton/32/273_2.png) [@rkevinburton](https://community.postman.com/u/rkevinburton)\
**Post date:** [July 3, 2020, 2:39am UTC](https://community.postman.com/t/pre-request-substitute-environment-variables/13853/1 "2020-07-03T02:39:57Z")

</div>

I have a pre-request script that looks like:

```
const auth0PostRequest = {
  url: 'https://burton.auth0.com/oauth/token',
  method: 'POST',
  header: 'Content-Type:application/json',
  body: {
    mode: 'raw',
    raw: JSON.stringify({"client_id":"{{mgt_client_id}}",
                         "client_secret":"{{mgt_client_secret}}",
                         "audience":"{{mgt_auth0_audience}}",
                         "grant_type":"client_credentials"})
  }
};

```

But when it runs I see that following request body in Postman Console.

`{"client_id":"{{mgt_client_id}}","client_secret":"{{mgt_client_secret}}","audience":"{{mgt_auth0_audience}}","grant_type":"client_credentials"}`

As can be seen, the script is expecting substitution of the variables between `{{ }}`

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 3, 2020, 5:59am UTC](https://community.postman.com/t/pre-request-substitute-environment-variables/13853/2 "2020-07-03T05:59:33Z")

</div>

Hey @rkevinburton,

You would need to reference those values like this in the sandbox:

```
{
    "client_id": `${pm.environment.get("mgt_client_id")}`,
    "client_secret": `${pm.environment.get("mgt_client_secret")}`,
    "audience": `${pm.environment.get("mgt_auth0_audience")}`,
    "grant_type": "client_credentials"
}
```
