How can Newman retrieve a variable with the latest value?

  • Newman cannot retrieve variable value from environment.json:

  • Question:
    request-1: (POST)Login to an account and create an account.
    response: account created with an id.
    request-2: (GET) Login and retrieve account’s information with the id.
    In Environments i have the following variables:

When i run the request-1 it creates the account and stores the id in variable id.
When i run the request-2 it retrieves account’s information with the id sent with the request.
So each time i create a new account the id is different.
Everything works fine with Postman.

I export collection of request-1 and request-2 in json format.
I export environnement in json format,

With Newman if i run request-1 like:
newman run c:\test\request-1.json -e c:\test\environment.json
it works.
With Newman if i run request-2 like:
newman run c:\test\request-2.json -e c:\test\environment.json
it works but the id is not the newest one, it gets from environement.json where id is static and never changes.

How can we run request-2 with newman with the latest id?

  • Platform Details:
    Version 10.24.15

Hey @ps198478320 :wave:,

What’s the script that you have that captures that data from the first request?

Do you need to have those values already exported in the environment file?

What values are actually being exported in the file?

Are they different values for the initial and current values, when you view you runs in Postman?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.