Currently, I am working on automating tasks using Postman
One interesting aspect is the presence of a vehicles array in the body
{
"Vehicles":[
{
"car":"{{car}}",
"bike":"{{bike}}"
}
]
}
My task requires me to modify it as shown below
{
"Vehicles":"[{{vehicles}}]"
}
To achieve this modification, I have created a pre-request script
let car, bike;
var vehicles = {
car: data.vehicles.car,
bike: data.vehicles.bike
}
pm.variables.set("vehicles", vehicles);
The data for the vehicles is sourced from an external file and looks like this
[
{
"Vehicles":[
{
"car":"BMW",
"bike":"YAMAHA"
}
]
}
]
I executed it through the collection runner and noticed that the request body showed vehicles:[object object]
, indicating that the data was not being successfully passed