Chaining request with Newman


I want to know how to chain requests in Newman, e.g. scenario as follows:

  1. GET request of a certain ID
  2. POST request with the ID variable obtained above

I know in postman we can make use of pm.environment.set etc. but how to implement the same method with Newman?

Appreciate your help.

Hi @tarekalba! Welcome to the community :wave:

Newman is a command line collection runner - so you can run chained requests as the same way as the collection runner.

Here’s how to run the command and include command options:

Hope this helps! Please let me know if you have further questions :wink:

Hi @taehoshino,
Thanks for the warm welcoming
I successfully chain the request in postman via pm.environment.set, however, newman is not reading the newly added value in environment. the value from the first request will be put in the body of the second request, and this until now failed when I use newman.

Do you have an example of newman scripts you can share that has this success?


Sorry guys, I just realized that when I export the environment to .json the current values will not be exported with it. The reason for the failures is I had the values of the environment variables in the Current column, so either I had to put them in the initial column or I have to write them manually in .json files.


@tarekalba Thanks for updating us :grinning:
Glad to hear you have found the solution :+1:

1 Like