I need to send a post request where the body of my schema has the following format with fixed data, arrays and objects:
{
“Ownerid”: “JohnDoe”,
“Animal” : “Cat”,
“Breeds”: [
{ “Breed”: “Siamese”,
“Color”:“Brown”
},
{ “Breed”: “Tabby”,
“Color”:“Orange”}
],
“Type”: “Domestic”
}
I need to be able to import a csv file where the data is added. This is what I did:
I created a csv with the columns being the variables and it looked like this:
Ownerid,Animal,Breed,Color,Type
JohnDoe,Cat,Siamese,Brown,Domestic
JohnDoe,Cat,Tabby,Orange,Domestic
I modified the body to include/get the variables so it looked like this:
{
“Ownerid”: {{Ownerid}},
“Animal” : {{Animal}},
“Breeds”: [
{ “Breed”: {{Breed}},
“Color”:{{Color}}
}
“Type”: {{Type}}
}
This works fine in Runner as long as each owner has only one animal (one row of data). As soon as I have more it separates the values into different post requests when it should be 1. Is there any way I can do this? I need the breed to contain as many cats as the owner has. This data should be in the rows of the csv file I am using in runner.
I’ve tried several code in the pre-request but nothing seems to work.