Dynamically passing a list to postman request via CSV or JSON file

I have a csv file with following details and request for my postman call is formed from this request…

Name,Age, DOB, period1,salaryPeriod1,Period2,SalaryPeriod2,Period3,SalaryPeriod3 etc

Here Period and Salary for the period is dynamic and different customers can have different number of periods.i.e (Period1 and SalaryPeriod is part of a list which can have any number of entries depending on customer)
So the number of entries for Period and SalaryPeriod how can I define dynamically ? As of now
if I wanted to test for different customer each time I need to update the CSV file with that particular customers period details…How can I dynamically update this period details in the CSV file ?

i.e. I am trying to add a dynamic list (which can have 1 to N occurances) into postman request

As of now i need to update CSV file for different customers as number of occurance for each customer is different

@sajeeshmurali Welcome to the Community :slightly_smiling_face:

How are these values from CSV is passed ? In body you are using form data or RAW?

Is it possible to set some dynamic variables to the desired fields, and remaining can come from the .CSV. Say like for example:

Period field can have {{$randomInt}}, instead of picking from the file. So you don’t need to update this every time in CSV for random values.

Thank You for your reply.

I am using collection runner and we have one csv to pass data but the the problem is one of the object is a list ( eg.membership period which have different fields like period from date,periodtodate,salary etc) and different customers can have different number of periods like some customer can have 5 periods, another customer can have 70 periods etc.

Currently, if customer have 10 periods then we need to repeat fields in the array 10 times in the CSV file (like period1fromdate,period1todate,salary1, period2fromdate,period2todate,salary2 etc till 10) .This also makes main CSV file very huge since some customers can have 75 to 100 periods.

We were trying to see whether is there any better way to dynamically pass this data to postman test?

It is not possible to use {{$randomInt}} because during testing we need to provide the actual data for that customer to verify the results and the calculation happens based on this data…

One option which I am thinking is to keep this period data as a separate CSV then expose it via rest endpoint and fetch it in pre request script and then prepare the input.

In this case main CSV file will have only information about which CSV to use to prepare member ship data and other basic fields.

In pre request script we will fetch that CSV with membership period data using rest GET call and then prepare the final data required for testing…

Pls suggest if you see any other better options here…

Thank You !

Is it possible to import another CSV file in pre request script and map that to an object in pre request script ?

Not from your local file system - You could send a request to an external location and bring in additional data that way.

u mean we need to make another rest call to get this file while exeucting pre request script ? no other option. ?

It’s difficult to understand from only explaining things with text, what you’re trying to do.

Can you provide some visual example of what you currently have in place and what the issues currently are?

It will be easier to see the problem with those examples.

Row first name LastName emp no fromDate(0) toDate(0) salary(0) salaryAdditional(0) fromDate(1) toDate(1) salary(1) salaryAdditional(1) fromDate(2) toDate(2) salary(2) salaryAdditional(2)

If you see above those are the fields which are available in the CSV file which I am using in collection runner while running tests and if you see the fields from date, todate, salary and salaryadditional (actually request have more fields in this array) those are part of an array.

In the above request, we have 3 occurrences but the problem is another customer can have 10 or 100 occurrences. I wanted to pass this array as a separate object to my postman test.

Currently, what I am planning to do is to keep this as separate CSV file, then fetch it via rest request and form the request in the pre-request script.

Is there any other better way to dynamically provide this input to my postman test?

Is it possible to access get data from multiple data files for my postman test ? My csv file is very huge so wanted to keep some of the objects in separate data files then I read these data files in pre request script to form the final request…Is this possible ?