2

I have a Postman test that executes a query based on the ID from that data-file (.csv), and supposed to return the "Name" (in the response). This data-file contains multiple entries. But the dilemma I have as following (I have 2 questions): 1. How can I have my test to loop thru each row, and execute the query for each of the values/rows in the data-file? 2. How can I output the needed value (in my case the "Name" only, and not the whole Response) into an output file?

Here is the Postman query: [GET] http://myurl.com/company({{COMPANY_ID}})

Here is the test portion of this call:

var jsonData = JSON.parse(responseBody);
console.log(jsonData.Name)

Here is an example of the .CSV data-file:

COMPANY_ID, COMPANY_LOCATION
2335, Alaska
4567, Mexico
6789, Hawaii
...

Here is the output I expect:

Company1
MyCompany
Company2
...
KVN
  • 863
  • 1
  • 17
  • 35

1 Answers1

3

Answer for question No1: You can use the Postman Runner or Newman for using your CSV datafile. enter image description here

You can access your data row by row by using data["<ColumnName>"] in your Test- or pre-request-script. In your case data["COMPANY_ID"] and data["COMPANY_LOCATION"]

Take a look here for further informations: https://learning.getpostman.com/docs/postman/collection_runs/working_with_data_files/

Answer for question No2: Unfortunately it is not possible to store date in files from PostMan without hacking. You can write your data into a global variable and export them later. An other option is to write your file over an other WebAPI service like DropBox.

DieGraueEminenz
  • 830
  • 2
  • 8
  • 18