# Saving variables in post-request script are not consistent

**URL:** <https://community.postman.com/t/saving-variables-in-post-request-script-are-not-consistent/84370>\
**Category:** Help Hub\
**Tags:** variables, collections, scripts, bug\
**Created:** [September 5, 2025, 7:15am UTC](https://community.postman.com/t/saving-variables-in-post-request-script-are-not-consistent/84370 "2025-09-05T07:15:40Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![vikpaw](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vikpaw/32/33597_2.png) [@vikpaw](https://community.postman.com/u/vikpaw)\
**Post date:** [September 24, 2025, 6:09pm UTC](https://community.postman.com/t/saving-variables-in-post-request-script-are-not-consistent/84370/9 "2025-09-24T18:09:16Z")

</div>

I have this issue too, it’s an absolute basic request to get an access token.

No collection or multiple requests. Only since latest update where we lost the intial value option.

Used postbot to confirm the post-response script. It even has a test to confirm the response value is set to the environment, and then i print to console. All good. But opening the environment tab and it’s not updated. Tried another request to use the variable in case it was a UI thing and it’s printing blank too.

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

// Check if the response has the access_token
pm.test("Access token exists in response", function () {
    pm.expect(response.access_token).to.exist;
});

// Save the access_token to an environment variable
pm.environment.set("access_token", response.access_token);

// Confirm that the access_token environment variable has been updated
pm.test("Access token environment variable is updated", function () {
    pm.expect(pm.environment.get("access_token")).to.equal(response.access_token);
});

// Output the access_token environment variable to console
console.log("Access token:", pm.environment.get("access_token"));

```

Test results: both PASSED

> **passed** Access token exists in response
> 
> **passed** Access token environment variable is updated

---

_[View the full topic](https://community.postman.com/t/saving-variables-in-post-request-script-are-not-consistent/84370)._
