# Postman doesn't accept using variables in the request body due to pre-request authorization script

**URL:** <https://community.postman.com/t/postman-doesnt-accept-using-variables-in-the-request-body-due-to-pre-request-authorization-script/2045>\
**Category:** Help Hub\
**Tags:** variables, authentication, pre-request\
**Created:** [July 6, 2018, 11:20pm UTC](https://community.postman.com/t/postman-doesnt-accept-using-variables-in-the-request-body-due-to-pre-request-authorization-script/2045 "2018-07-06T23:20:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantin.V](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/konstantin.v/32/776_2.png) [@Konstantin.V](https://community.postman.com/u/Konstantin.V)\
**Post date:** [July 6, 2018, 11:20pm UTC](https://community.postman.com/t/postman-doesnt-accept-using-variables-in-the-request-body-due-to-pre-request-authorization-script/2045/1 "2018-07-06T23:20:38Z")

</div>

**Describe the bug**  
I’d like to use variables in the request body but Postman didn’t accept that due to my pre-request authorization script, so I get `401 Unauthorized` error.

Any suggestions how can I fix that are very apreciated.

**Request headers:**

```auto
User-Agent:ApiRequestTask/1.0
Content-Type:application/vnd.api+json
Accept:application/vnd.api+json
Authorization:{{AuthorizationToken}};{{AuthorizationSignature}}

```

**Request body:**

```auto
{
  "data": {
    "type": "password_request",
    "attributes": {
      "email_address": "{{user.email}}"
    }
  }
}

```

**Athorization pre-request script:**

```auto
var secret = pm.environment.get("AuthorizationSecret");

var body = '';
var hash = '';

if(request.method == 'GET') {
    hash = CryptoJS.HmacSHA256('', secret).toString(CryptoJS.digest);
} else {
    hash = CryptoJS.HmacSHA256(request.data, secret).toString(CryptoJS.digest);
}

postman.setEnvironmentVariable("AuthorizationSignature", hash);

```

**Screenshots**

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/e/ae396bff300b48ee777139ea349c7ef1c78d4614.png)  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/1/1140e8c065be14f9f9ee332bf467fb7d669b9989.png)

**App information:**

- App Type: Native App
- Postman Version: 6.1.4
- OS: macOS High Sierra 10.13.5

---

<div class="post-metadata">

**Author:** ![kunagpal](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kunagpal/32/9_2.png) [@kunagpal](https://community.postman.com/u/kunagpal)\
**Post date:** [July 6, 2018, 11:24pm UTC](https://community.postman.com/t/postman-doesnt-accept-using-variables-in-the-request-body-due-to-pre-request-authorization-script/2045/2 "2018-07-06T23:24:53Z")

</div>

@Konstantin.V It appears that you’re trying to access nested properties (`api.stage` and `user.email`), which is not currently supported. You’ll have to store the URL and email values as distinct variables, and then access them with the usual `{{...}}` syntax.

---

<div class="post-metadata">

**Author:** ![Konstantin.V](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/konstantin.v/32/776_2.png) [@Konstantin.V](https://community.postman.com/u/Konstantin.V)\
**Post date:** [July 26, 2018, 6:54am UTC](https://community.postman.com/t/postman-doesnt-accept-using-variables-in-the-request-body-due-to-pre-request-authorization-script/2045/3 "2018-07-26T06:54:31Z")

</div>

Hey @kunagpal,  
yes, of course my URL and email values are stored as variables, this is not the source of my issue.

The problem was related to my pre-request authorization script and this solution helped me to resolve it:

```auto
var data = request.data.replace('{{user.email}}', 
postman.getEnvironmentVariable("user.email"));

```
