# Error on setting variables ( Cannot read properties of undefined )

**URL:** <https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [February 4, 2026, 9:25pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450 "2026-02-04T21:25:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 4, 2026, 9:25pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/1 "2026-02-04T21:25:05Z")

</div>

Hi, I’m trying to set my env to store `jwt` token, and no matter what I tried I can’t see it working, no value in Env section. I typed this code in ``cripts` section, tried for local/global:`

```auto
const response = pm.response.json();
const jwt =responseJson.jwt;

```

````auto
pm.globals.set(‘jwtGLobal’,‘Bearer ${jwt}’);
pm.variables.set(‘jwtLocal’,‘Bearer ${jwt}’);```

````

Console message says:  
`TypeError: Cannot read properties of undefined (reading ‘json’)`

What I’m doing wrong, this setup was working 3-4 months ago for me.

Thanks

Vic

---

<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:** [February 4, 2026, 9:33pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/2 "2026-02-04T21:33:56Z")

</div>

Hey @dainova17

It looks like you have a mismatch with your variable names:

```auto
const response = pm.responese.json();
const jwt =responseJson.jwt;

```

You’d need to remove the extra `Json` part.

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 4, 2026, 10:58pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/3 "2026-02-04T22:58:09Z")

</div>

Thanks Danny,  
Let me check, in your reply you still have extra `json` part, right ? It’s look identical, less typo in `responEse`

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 4, 2026, 11:05pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/4 "2026-02-04T23:05:53Z")

</div>

Something is weird in my setup, no matter what command I ran I get same error ,even for  
`_console_.log("Set authToken variable “)`. And I do SAVE .

---

<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:** [February 4, 2026, 11:19pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/5 "2026-02-04T23:19:16Z")

</div>

I just copied your code and left that in there so I could explain where it was in the script. 🙏🏼

Do you have any other scripts in the Collection level or Request level that’s trying to access the JSON.

As I can’t see what you have in front of you it’s tough for me to point you in a specific direction.

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 4, 2026, 11:42pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/6 "2026-02-04T23:42:28Z")

</div>

Thanks much ,Danny. Let me do my homework. I will try to do brand new setup.

---

<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:** [February 4, 2026, 11:47pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/7 "2026-02-04T23:47:45Z")

</div>

You’re welcome.

It might also be worth checking the pre-request scripts too.

It would likely show the same error message if you’re trying to grab the response, before the main request is sent.

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 5, 2026, 2:01am UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/8 "2026-02-05T02:01:46Z")

</div>

Made brand new env, and have the same result, in this case Script section is empty for both Pre and Post-Response.Post works fine, status =200, see jwt generated. Maybe I can just ignore this message on console?

 ![sw1](https://us1.discourse-cdn.com/getpostman/original/3X/4/9/490404bf7ece7d3eb069e90ed566332a56814a27.jpeg)

---

<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:** [February 5, 2026, 8:07am UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/9 "2026-02-05T08:07:18Z")

</div>

What is the content type header for the response?

In the image, did you manually change that to `Raw` or was it returned like that?

It looks like it’s returning that as a string, that looks like JSON. It might be a request/response header missing somewhere though. It would be throwing that error because it’s trying to parse that string as JSON in the `pm.response.json()` method.

You can use `pm.response.text()` but you would then need to add some additional logic to extract the value you need. I would personally look closer at the headers first.

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 5, 2026, 4:25pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/10 "2026-02-05T16:25:12Z")

</div>

Hi Danny,  
Here it is : application/x-www-form-urlencoded

 ![HeadersX](https://us1.discourse-cdn.com/getpostman/original/3X/d/6/d6194492b8751613bf6453774c88215d0518fa22.jpeg)

I might changed output to RAW to troubleshoot in first pic, here is what I have by default = JSON, it’s look OK for both. I’m sure it’s Json, b’z it worked OK with variable a month ago.

 ![vs](https://us1.discourse-cdn.com/getpostman/original/3X/7/b/7b364ce083a70de4c52f0c7f337583c64c745f1d.png)

Could be be in some other call inside of my collections? They all GETs. And I’m running only one PUT.  
THanks so much

V

---

<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:** [February 5, 2026, 6:44pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/11 "2026-02-05T18:44:00Z")

</div>

Can you remove the manually added request content-type header, so that the auto generated one will be applied.

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 5, 2026, 7:24pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/12 "2026-02-05T19:24:35Z")

</div>

I didn’t enter it manually, was there probably already with my demo. (application/x-www-form-urlencoded)  
Unchecked, and got error on body like below:

 ![xf](https://us1.discourse-cdn.com/getpostman/original/3X/9/d/9d09920c5a437fe658b4cf983179ce253f1f87d4.jpeg)

---

<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:** [February 5, 2026, 7:59pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/13 "2026-02-05T19:59:03Z")

</div>

What happens when you add the `content-type: application/json` header?

---

<div class="post-metadata">

**Author:** ![dainova17](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dainova17](https://community.postman.com/u/dainova17)\
**Post date:** [February 5, 2026, 9:17pm UTC](https://community.postman.com/t/error-on-setting-variables-cannot-read-properties-of-undefined/88450/14 "2026-02-05T21:17:51Z")

</div>

> [@danny-dainton](#):
>
> application/json

IT’s same error, original content-type worked fine still. Overall I don’t have any issues with this API running it in python, just trying to do some automation in Postman.  
“error”: “invalid\_request”,

```
"error_description": "Invalid Content Type"

```

Thanks much Danny and all for help.

V
