2

I am trying to read the entire test data file as a part of pre-request script in postman.

I tried the variable pm.iterationData, however ,it prints only the current iteration data set in the colletion runner. I need the entire test data and load it as an environment variable in postman.

Is there a way?

Raghav
  • 67
  • 2
  • 9

2 Answers2

0

The solution that i could find for this is, to set the test data in a variable as a part of pre-request script as follows:

let testdataset = 
[
{
    "name": "xyz",
    "address": "abcd",
    "value": "Hello"    
},
{
    "name" : "mno",
    "address" : "defg",
    "value" : "Mnop"
}
];
Raghav
  • 67
  • 2
  • 9
0

The best way I have come up with dealing with this (collecting all data from a file to us in one request) is to:

  1. Have 2 nodes
  2. The first node has

    • A dummy call to something like https://postman-echo.com/
    • Code that: i. stores the table headers in an environment variable; ii. concatenates the rows into environment variables; iii. does 'postman.setNextRequest(null)' for all but the last row
  3. The second node

    • Only runs in the last iteration
    • Sends collected data in the environment variable to the API

There is (currently) no way to not make any call on the first node at the moment.

See Github ticket for a request to do this: Request a way for nodes in collection to be logic-only, no request issued #5707

TenguTech
  • 21
  • 5