# Why are specified variables not being remembered?

**URL:** <https://community.postman.com/t/why-are-specified-variables-not-being-remembered/64254>\
**Category:** Help Hub\
**Tags:** variables, collections\
**Created:** [July 18, 2024, 11:25am UTC](https://community.postman.com/t/why-are-specified-variables-not-being-remembered/64254 "2024-07-18T11:25:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacecraft-engineer2](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/spacecraft-engineer2/32/25710_2.png) [@spacecraft-engineer2](https://community.postman.com/u/spacecraft-engineer2)\
**Post date:** [July 18, 2024, 11:25am UTC](https://community.postman.com/t/why-are-specified-variables-not-being-remembered/64254/1 "2024-07-18T11:25:29Z")

</div>

Good afternoon  
I am sending a GET request `{{base_url_zakaz}}abonents/v0/abonents?Inn=5534183182&Kpp=553401001`

In order to remember the variables, abonentId and requisiteId, received in response to this request. I write down 2 scripts in the Post-Response Script tab:

```auto
pm.globals.set('abonent_Id', pm.response.json().abonentId);
pm.globals.set('requisite_Id', pm.response.json().requisiteId);

```

In response to the request I receive a status of 200 Ok.  
And in the body of the response, the necessary variables:

```auto
[
    {
        "abonentId": "2202db26-15cb-4abc-a33b-997f966e8043",
        "requisites": {
            "requisiteId": "3a44b0c9-cc36-41d9-9fa2-9578f139e9bd",
            "inn": "5534183182",
            "kpp": {
                "value": "553401001",
                "organizationKppType": 1
            },
            "clientType": 1,
            "name": "LLC Organization Name"
        },
        "accounts": []
    }
]

```

However, at the same time, in the “Environment Quick Look” tab. For some reason, Postman does not remember the variables received in the body of the response to the request.

In this case, in each of the variables, abonent\_Id and requisite\_Id, the value is null as the Current Value.

Question: What am I doing wrong and specifying in the request, which is why the specified variables are not being remembered?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/5/9569a010fef2df38104317000659d850562f637b.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/c/aceb205b2c39b1c41ae2c16eb595d16349d11ceb.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/f/5f37a7132cce89f0c50993ce0ee445d21e19f5dd.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/7/a76a38ebc3ceed0b8b78aecbbe3709356b955151.png)

---

<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 18, 2024, 1:35pm UTC](https://community.postman.com/t/why-are-specified-variables-not-being-remembered/64254/2 "2024-07-18T13:35:21Z")

</div>

Hey @spacecraft-engineer2 👋

The is down to the references that you’re making to that response data:

```auto
[
    {
        "abonentId": "2202db26-15cb-4abc-a33b-997f966e8043",
        "requisites": {
            "requisiteId": "3a44b0c9-cc36-41d9-9fa2-9578f139e9bd",
            "inn": "5534183182",
            "kpp": {
                "value": "553401001",
                "organizationKppType": 1
            },
            "clientType": 1,
            "name": "LLC Organization Name"
        },
        "accounts": []
    }
]

```

It’s an `array`, with an `object` inside it. Directly going to the `abonentId` property would result in it being _undefined_. You need to **first** specify which `object` within the `array`, you want to access.

The _Postman Console_ is your friend here, you can use this to see what would be the result if you were to reference things in certain ways.

This is an example of what you’re doing vs accessing the object first:

```auto
console.log(pm.response.json().abonentId)
console.log(pm.response.json()[0].abonentId)

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/b/9b112986bccfb7aeb0c0368f4a0f93f17b6953a6.png)

* * *

[I’ve previously shared this with you](https://community.postman.com/t/capture-the-response-body-values-as-variables/51667/6) in a different thread but this will hopefully explain again how to extract different pieces of data from a response body:

> [@Sharing tips and tricks with others in the Postman community](https://community.postman.com/t/sharing-tips-and-tricks-with-others-in-the-postman-community/5123/5):
>
> Extracting values from a JSON response I notice lots of questions from the community which all have a similar flavour - Users are having trouble extracting data from a JSON response body when the value is within an array. These are normally JavaScript related questions, more than specific Postman questions but I want to use this thread to offer more support around this problem. For these examples I’ll be using the [https://randomuser.me](https://randomuser.me) API, this returns lots of random user data, in a JSON form…

---

<div class="post-metadata">

**Author:** ![spacecraft-engineer2](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/spacecraft-engineer2/32/25710_2.png) [@spacecraft-engineer2](https://community.postman.com/u/spacecraft-engineer2)\
**Post date:** [July 18, 2024, 8:13pm UTC](https://community.postman.com/t/why-are-specified-variables-not-being-remembered/64254/3 "2024-07-18T20:13:11Z")

</div>

Danny Thank you very much!! This is not the first time your method has helped me. It’s good that there are such good specialists like you!! 🙂

P.S. I’m already writing my next request to you…

---

<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 21, 2024, 8:13pm UTC](https://community.postman.com/t/why-are-specified-variables-not-being-remembered/64254/4 "2024-07-21T20:13:24Z")

</div>

Closed on July 21, 2024, 8:13pm UTC

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