Environment variable not updated via Run Collection

I have a collection with 2 requests (create_user and get_user).
When I run create_user request , userid is generated .I set this userid as environment variable.
Then I run get_user request it picks userid from environment variables and gets user info accordingly.
It all works perfectly when I run each request separately one by one.
But when I run it via collection, environment variable is not updated.
Please advise, what can it be.

Can you please provide screenshots of what you’ve got.

There is no reason that this shouldn’t work if you have the correct environment set.

Thanks for reply, Mike! Please see attached screenshots.
Create User pre Request


Which one is failing, or are they all failing?

This is where the console log comes into play.

As soon as you set the environment variable, use pm.environment.get to retrieve it again. This should give you confidence that the variable is indeed set.

Start with the first request.

You can also put this in the tests tab and console log those variable before you have the pm.test block.

Are you 100% sure you have the environment selected when using the collection runner? I assume you are running this via the Collection runner. If you are using something else like the CLI or Newman, you will need to tell us. Make sure you tick the option to persist responses in the collection runner, and this will give you another place to check things out.

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