I’m working on a test that uses a csv file to take in a wide number of parameters. Within the request I send an array. Usually that array is of a specific size, but it’s possible that array could change in size. This is reflected in the csv file I use to populate the data. I’ll give an example
Standard file without issue
|TEST ID|EXTRA|Variable1|Variable2|
|ID1|0|1|A|
|ID2|0|2|B|
|ID3|0|3|C|
|ID4|0|4|D|
But every so often I receive a file that looks like this
|TEST ID|EXTRA|Variable1|Variable2|
|ID1|0|||
|ID2|0|2|B|
|ID3|0|3|C|
|ID4|0|4|D|5|E|
It’s possible I could be handed a set that either contains nothing in the place of ‘Variable1’ and ‘Variable2’, which is expected for testing. Or as in the case of line 4, has extra fields not found in lines 2 or 3. Is there a method to handle those extra fields containing ‘5’ and ‘E’ without adding headers?
What I’m looking for is if it’s possible to change the response body in my Pre-request so on line 2’s test I can send
"arrayName": [
{
"Variable1": "3",
"Variable2": "C"
}
]
While on line 4’s test, I can send
"arrayName": [
{
"Variable1": "4",
"Variable2": "D"
}
{
"Variable1": "5",
"Variable2": "E"
}
]
I could theoretically add a header for each variable in the csv, but then it would almost be easier to just create the tests by hand for each line in the csv.