How to pass argument or value while running collection from newman

How to pass argument or value while running collection from newman ?

newman run mycollection.json -e envfile.json/csv is not working

Scenario

I have a collection which can run on multiple environments seamlessly but i need to pass one argument/value in first API request body which while drive to run on multiple environment

Steps to reproduce the behavior:

  1. Go to newman
  2. Run collection

I need to know how can i run collection by passing one value in command line

Collection link
https://www.getpostman.com/collections/ca4042cf3c3280013986

In above collection i need to pass organization id in first API

API name getDomain API
Request body
{“orgid”: “give_org_id_here”}

Could you please let me know the solution for this ?

I tried many things like passing environment json/csv file but nothing worked because environment json/csv files have only variable key doesn’t have variable value

You can specify environment or global variables directly on the CLI like this:

–global-var “foo=bar”

Does it provide you with a solution?

Hi vdespa,

Thanks for your response,

But it is not working

Here is the scenario

In my collection , i need to pass value for the first API

Below is the Request body of first API to which i need to send value form CLI

{
“orgid”: “{{domain}}”
}

In above request body {{domain}} is the user defined variable name to which i need to send value from CLI

below command i am using as per your suggestion

newman run mycollection.json -global-var “domain=value” , its giving me below
error: unknown option -o

newman run mycollection.json -g “domain=value” , its giving me below
error: ENOENT: no such file or directory, open ‘C:\Users****\Desktop\27082019\domain=00D1U000000GqnbUAC’

It looks like you’re using the -g flag which would be telling Newman to use a global variable file path or URL.

You need to use –global-var to pass in the argument like you’re doing in the command.

Hi

Thank you

It worked with below command …

–global-var “=”

1 Like