1

I'm creating test automation scripts through postman. I want to pass a nested array in postman body

{
   "fruit":{{fruit}},
   "Vehicles":[
      {
         "car":{{car}},
         "bike":{{bike}}
      }
   ]
}

I want to pass the vehicles array.

When I executed the APIs I get these vehicles as a empty variables. data is not passing

The Response body as follows

{
   "fruit":"mango",
   "Vehicles":[
      {
         "car":{{car}},
         "bike":{{bike}}
      }
   ]
}

The external json data file

[
   {
      "fruit":"mango",
      "Vehicles":[
         {
            "car":"BMW",
            "bike":"YAMAHA"
         }
      ]
   }
]

I'm executing this with postman collection runner and data inside the nested array is not passing.

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
Erandi Dilshani
  • 335
  • 1
  • 4
  • 11

1 Answers1

1

Your request body is not valid JSON, after the values from the file have been inserted. You don't have quotation marks araound the values.

Try this:

{
   "fruit":"{{fruit}}",
   "Vehicles":[
      {
         "car":"{{car}}",
         "bike":"{{bike}}"
      }
   ]
}
Christian Baumann
  • 3,188
  • 3
  • 20
  • 37