Environment dynamic variables in Newman

I have an env variable that gets generated after initial requests.
for example:

1 - I get a value from a ‘Request 1’ [value is different every time]
2 - I set the ‘Request 1’ Value in TESTS to Env variable [e.g variable key and value is xxx and it stores in Current Value]
3 - I use the ‘key’ variable in ‘Request 2’ and so on

now when I run this in Newman via exporting envr.json, it won’t be working since my initial value (KEY) is not there. Thus I used ‘API-Key’ to hit my Env variables values.

The issue is that Newman accepts the ‘INITIAL VALUE’ whereas my Tests are setting the variables in ‘Current Values’

How can I assign the Dynamic Current Values to ‘Initial Values’ at the time I set the env variable in TESTS, so I could use those Values through Newman?

my Newman command is:
newman run https://api.getpostman.com/collections/collectionUId?apikey= 1234 --environment https://api.getpostman.com/environments/environmentUId?apikey=1234

You should run the request that sets that environment variable from Newman as well.

Otherwise, you need to manually persist it from Postman.

Thank you for the message. Yes, I do run the request using the API key. however, it Fails, as it does not assign the variable value to ‘Initial Value’, Yes If I manually persist it from Postman then it reads the values. However, it is not helpful as my Values change one ever request. The older Postman version had the option in setting to automatically set the ‘initial values’ however it is not available in the latest versions, therefore I was wondering if this can be achieved in code while setting the env variables? if No then what is the different approach I can use.
In my case, I have to set an env variable from each request and pass it to the next like a chain of variables.

Hi guys,

I have the same flow and the same issue with initial values in Newman was arise. Any update?

1 Like

any help?
sama thing