# Environment variables from pm.response body

**URL:** <https://community.postman.com/t/environment-variables-from-pm-response-body/40351>\
**Category:** Help Hub\
**Tags:** variables, json\
**Created:** [October 22, 2022, 8:08pm UTC](https://community.postman.com/t/environment-variables-from-pm-response-body/40351 "2022-10-22T20:08:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuliia](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yuliia/32/13634_2.png) [@Yuliia](https://community.postman.com/u/Yuliia)\
**Post date:** [October 22, 2022, 8:08pm UTC](https://community.postman.com/t/environment-variables-from-pm-response-body/40351/1 "2022-10-22T20:08:30Z")

</div>

Hi dear team. I’m completely new to the Postman, I’m learning it)  
So i have a task to do environment variable from the response body.  
The issue is in request body i set:  
“email”: “{{$randomEmail}}”

In Test i set environment variable as:  
pm.environment.set(“emailvariable”, “pm.response.json().user.email”);

after running in my env variables i don’t see email from response, but have a script…  
What is wrong?

Screenshoots:

> **[Screenshot](https://prnt.sc/6qcL81Ao7X0u)**
>
> Captured with Lightshot

> **[Screenshot](https://prnt.sc/NWwGPR8WTTpv)**
>
> Captured with Lightshot

> **[Screenshot](https://prnt.sc/kPUzTNpZXJtT)**
>
> Captured with Lightshot

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [October 23, 2022, 4:32pm UTC](https://community.postman.com/t/environment-variables-from-pm-response-body/40351/2 "2022-10-23T16:32:38Z")

</div>

Hi @Yuliia

You need to remove the quotes from the value part of the environment set.  
(If you use quotes here you are passing the value as a string… but you want to refer to a value within your response).

Try this;  
`pm.environment.set(“emailvariable”, pm.response.json().user.email);`
