user2156115
user2156115

Reputation: 1257

How to use iteration data with newman

I have a collection in Postman which loads "payload objects" from a json file and want to make it run in newman from command like.

POST request

and a file.json file with this kind of "objects":

[
    {
    "data": {
        "propert1": 24,
        "property2": "24__DDL_VXS",
        ...
    },
        {
    "data": {
        "propert1": 28,
        "property2": "28__HDL_VDS",
        ...
    }
...
]

Works like a charm in Postman.

Here is what I'm trying to run in cmd.

newman run \
-d file.json  \
--global-var access_token=$TOK4EN \
--folder '/vlanspost' \
postman/postman_collection_v2.json

Based on the results I am getting - it looks like that newman is not resolving flag:

-d, --iteration-data <path> Specify a data file to use for iterations (either JSON or CSV)

and simply passes as payload literally this string from Body section: {{jsonBody}}

Anyone has got the same issue ?

Thx

Upvotes: 2

Views: 4348

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

I did that way and it worked.

  1. Put collection and data file into a same directory. For example:
C:\USERS\DUNGUYEN\DESKTOP\SO
        ---- file.json
        \___ SO.postman_collection.json
  1. From this folder, make newman command.
newman run .\SO.postman_collection.json -d .\file.json --folder 'vlanspost'
  1. This is the result:

enter image description here

Upvotes: 1

Related Questions