1

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?

karel
  • 5,489
  • 46
  • 45
  • 50
Franco
  • 875
  • 1
  • 6
  • 14
  • Using postman runner you have the possibility to add that array of data that you posted as an example. You can create the testdata as an array in a separate file and use it in the runner http://blog.getpostman.com/2014/10/28/using-csv-and-json-files-in-the-postman-collection-runner/ – Jan Nielsen Sep 28 '18 at 08:23

0 Answers0