How can I run a collection with specified environment via Newman

I have a collection for specified environment.
How can I run that collection for that environment via Newman?

For example: In my collection I have this kind of requests:
{{url_production}}/streams/remove/{{private collection id}}.json?key{{json_key}}

{{url_production}} - environment
{{private collection id}} - global
{{json_key}} - global

I have exported both the environment and the Collection JSON files but when I run the collection via Newman all cases are going to fail. (See the screenshot)
How this will be done?
Screenshot%20at%20Jun%2004%2012-04-34

P.S the the values of globals which are mentioned in the url are generated by previous requests in the collection.
How can we do with globals as well? I mean every time after sending the same request I should get different values of globals and this collection I need to run via Newman.
Thanks in advance.

It seems that the environment was not picked up by newman.

Are you sure you have specified it using --environment and that the path is correct?

2 Likes

@sero.barseghyan As @vdespa mentioned you are either referencing your environment JSON file incorrectly or not at all.

Can you give us a sample of the command you are issuing so we can see the parameters you are passing?

Newman basically requires 2 parameters to be able to run. The Collection and the Environment, everything else is optional, so by the sounds of it you may just have a small config issue here.

1 Like