Search code examples
collectionspostmanpostman-newmanpostman-collection

How to run postman Collection and Environment in CMD using newman by using Postman APIKey


I want to run my postman Collection and Environment in CMD using newman by using Postman-APIKey.

What I tried:

newman run "https://api.getpostman.com/collections/{{collectionKEy}}?apikey={{APIKey}}&EnvironmentKey={{EnvironmentKey}}"

After running, I get the following error for every requests which using environment variables:

"runtime:extensions~request: request url is empty"

Or is there any other way to use both Environment and Collection?


Solution

  • It appears that your newman command is incorrect, the correct syntax to run a collection with an environment would be:

    newman run https://api.getpostman.com/collections/$uid?apikey=$apiKey -e https://api.getpostman.com/environments/$uid?apikey=$apiKey
    

    Full details and all the cli commands can be found on the Newman repo:

    https://github.com/postmanlabs/newman