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.

3
  • 1
    Really, don't understand the question. Are you trying to read data from external data file? Commented Mar 23, 2022 at 8:44
  • Yes @lucas-nguyen-17 Commented Mar 23, 2022 at 9:00
  • I think you got it wrong. Read this article blog.postman.com/… then edit your json file. Commented Mar 23, 2022 at 13:47

1 Answer 1

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}}"
      }
   ]
}
Sign up to request clarification or add additional context in comments.

1 Comment

This is worked for me thanks:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.