In a Mock service, only the Initial variable is always used but I need the Current value

Postman version 9.21.2

Use a Mock service.

GET request


The incoming request has a field: QR

I store the value of QR via an environment variable (variable_QR) in this way:

let param = pm.request.url.query.toObject().QR;

pm.environment.set (“variable_QR”,param);

This goes well and is kept as Current value.

Then I fill the response with this variable (variable_QR)

“qr”: {{variable_qr}}

The big problem is that the Initial value comes into the response and not the Current value.

Is there a possibility/script to get the Current value in the response?

Or is it possible to update the Initial with the Current value via a script?

Or is there another solution?

I look forward to a solution.



Hi @vvdkuij

I was trying to replicate your scenario but mine seems to pull in the current value not the initial.

Could you maybe provide some screenshots of what you have tried? and include the console log output too?


Hi James, thank you for the comment.

These are the screenshots.

Postman version 9.19

Request gives a Response via Mock


<img width=“602” height=“135” style=“width:6.2708in;height:1.4062in” id=“Afbeelding_x0020_5” src="//" alt="Afbeelding met tafel

Automatisch gegenereerde beschrijving">

<img width=“588” height=“89” style=“width:6.125in;height:.927in” id=“Afbeelding_x0020_4” src="//" alt="Afbeelding met tekst

Automatisch gegenereerde beschrijving">

Example Body:

<img width=“454” height=“216” style=“width:4.7291in;height:2.25in” id=“Afbeelding_x0020_3” src="//" alt="Afbeelding met tekst

Automatisch gegenereerde beschrijving">

Executing the request fills the Current value:

Environment variables

<img width=“601” height=“101” style=“width:6.2604in;height:1.052in” id=“Afbeelding_x0020_2” src="//" alt="Afbeelding met tafel

Automatisch gegenereerde beschrijving">

But I get the Initial value in my response:

I want 111111;111111 (Current value) in the resposne and not 1234 (Initial value).

Ahhh I see now. Yeah, I don’t think you can pass ‘current’ variables to a mock server;
(If anyone wants to correct me on this, I’d be really intrigued by the solution).

There is a thread here with a similar scenario;

And in here they discuss;

That got me thinking along the right track and it ALL came clear … the current variables CAN’T be shared with the mock server cause they aren’t serialized or stored on the postman servers.

Ok, that’s clear…. very unfortunate.

Is there really no script that passes the value of a Current variable to an Initial varibale?