Collection variable stopped persisting overnight


#1

I’m sure I’m overlooking something simple, but my collection variable setting has seemingly stopped working overnight.

I have a request where I get back a MongoDB record with an _id property and I save it to a gameId variable in the Tests tab like this:

const response = JSON.parse(responseBody); postman.setEnvironmentVariable('gameId', response._id);

If I log the variable out after setting it there it works as expected. However, when I switch to the next request and try to use this variable in the request body, the field in the request body comes through as the string {{gameId}}, not the value of the variable set in the previous request. If I log out the gameId variable here it is now unset.

I’ve tried using pm.environment.set() and many other variations found in the documentation but to no avail.

This is a sample of the request I’m sending with the Postman variable in the body:

{ "_game": "{{gameId}}", "name": "Connect Four" }

As described above, the value of this gameId variable no longer persists from one request to the next despite it working fine last night with seemingly no changes.