# Saving variable sent in json

**URL:** <https://community.postman.com/t/saving-variable-sent-in-json/22641>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [April 14, 2021, 4:58pm UTC](https://community.postman.com/t/saving-variable-sent-in-json/22641 "2021-04-14T16:58:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdolan90](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cdolan90](https://community.postman.com/u/cdolan90)\
**Post date:** [April 14, 2021, 4:58pm UTC](https://community.postman.com/t/saving-variable-sent-in-json/22641/1 "2021-04-14T16:58:48Z")

</div>

Hi, So I’m trying to save a dynamic variable thats sent in the json on a post. Im using the faker.js library and sending my json like so  
{  
“email”: “{{email}}”,  
“password”: “{{password}}”  
}

This works fine up to this point, But I’ve been trying to save the result that email sends as a variable as I cannot fetch it in the json after it is sent, since that endpoint is only returning something like a GUID and an ID number but no email. I want to use this email in my further tests to login, but it seems I can only save the variable as {{email}} which gives me a new one each time.

---

<div class="post-metadata">

**Author:** ![hannah.neil](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/hannah.neil/32/4477_2.png) [@hannah.neil](https://community.postman.com/u/hannah.neil)\
**Post date:** [April 15, 2021, 6:52pm UTC](https://community.postman.com/t/saving-variable-sent-in-json/22641/2 "2021-04-15T18:52:37Z")

</div>

Hi @cdolan90 ! I saw your note that you’ve figured out a solution. Do you mind sharing here what worked for you? I’m willing to bet that someone else may have a similar question down the line, and your solution can certainly help others 🙂

---

<div class="post-metadata">

**Author:** ![cdolan90](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cdolan90](https://community.postman.com/u/cdolan90)\
**Post date:** [April 15, 2021, 7:28pm UTC](https://community.postman.com/t/saving-variable-sent-in-json/22641/3 "2021-04-15T19:28:45Z")

</div>

Sure, so I just created a new variable with the data from the test as a pre-request script

`var randomEmail = pm.collectionVariables.get("email"); `

`postman.setEnvironmentVariable("testLoginEmail", randomEmail);`

This grabs the email when it is sent in the request, puts it as an variable for future tests, just be sure to unset it with

```auto
pm.environment.unset("variable_key");

```

---

<div class="post-metadata">

**Author:** ![hannah.neil](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/hannah.neil/32/4477_2.png) [@hannah.neil](https://community.postman.com/u/hannah.neil)\
**Post date:** [April 19, 2021, 11:42pm UTC](https://community.postman.com/t/saving-variable-sent-in-json/22641/4 "2021-04-19T23:42:41Z")

</div>

👏 👏 👏

Glad you figured it out, and thanks for sharing!
