I want to fetch from data file (JSON) in the collection Runner an array of object. I have my collection in the main app here the body with all the fields that are parameterized.
{
"order": {
"order_date": "{{order_date}}",
"order_number": "{{order_number}}",
"reference": "{{reference}}",
"shipping_method": "{{shipping_method}}",
"signature_required": {{signature_required}},
"destination": {
"name": "{{name}}",
"phone": "{{phone}}",
"email": "{{email}}",
"company": "{{company}}",
"building":"{{building}}",
"street": "{{street}}",
"suburb": "{{suburb}}",
"city" : "{{city}}",
"state": "{{state}}",
"post_code": "{{post_code}}",
"country": "{{country}}",
"delivery_instructions": "{{delivery_instructions}}"
},
"items": [
{
"description": "My Item",
"sku": "ItemA",
"quantity": 1.0,
"weight": 0.60,
"value": 25.0
}
]
}
}
As you can see order.fields are all parameterized and I can fetch a lot of different data for many iterations I like adn I can iteract dynamically with the API underlying. However the array of object/s items is static.
This below is my data file example (I have just pasted one scenario, but I have files with 50)
[
{ "signature_required": true,
"reference": "Test1",
"shipping_method":"express",
"order_number": "{{randomOrderNumber}}",
"order_date" : "{{$timestamp}}",
"name" : "Company + Building + City",
"phone" : "00000000",
"email": "test@test.com",
"company": "My Company",
"building": "My Building",
"street": "20 Wellington Street",
"suburb": " Bondi",
"post_code": "2026",
"state": "NSW",
"city": "Sydney",
"country": "Australia",
"delivery_instructions": "Leave at front-door"
},
....
....
....
]
Is there any way i can add an array of 1 or more objects with different variables in the data file template I have created? Maybe something like this:
[
{ "signature_required": true,
"reference": "Test1",
"shipping_method":"express",
"order_number": "{{randomOrderNumber}}",
"order_date" : "{{$timestamp}}",
"name" : "Company + Building + City",
"phone" : "00000000",
"email": "test@test.com",
"company": "My Company",
"building": "My Building",
"street": "20 Wellington Street",
"suburb": " Bondi",
"post_code": "2026",
"state": "NSW",
"city": "Sydney",
"country": "Australia",
"delivery_instructions": "Leave at front-door"
"items":[
{
"description": "My Item1",
"sku": "Item1",
"quantity": 1.0,
"weight": 0.60,
"value": 25.0
},
{
"description": "My Item2",
"sku": "Item2",
"quantity": 1.0,
"weight": 0.60,
"value": 25.0
},
]
},
....
....
....
]
What would be the code in the request template? What would be the code in the data_file.json?