I am trying to build a query filter as an array. So, To make a GET call with some filter in the postman, I'd built an query like:
"query": [
{
"key": "type",
"value": 3
},
{
"key": "type",
"value": 4
},
{
"key": "type",
"value": 5
}]
It made the URLs with filter, like
/api/3/vehicles/?type=3&type=4&type=5
But these filters should be getting from previous API call. So, I'd built some script that builds the query like above and save it in the environment variable.
query = []
for (i = 0; i < data.length; i++){
query.push({'key': 'type', 'value': data[i].id})
}
postman.setEnvironmentVariable("query", query);
And, in the JSON file, I used it like:
"query" : {{query}}
But it seems postman can't recognize it as an environment variable. I can't even import JSON file to the postman. I am getting a format error. Is this something you faced before? How I can solve this problem?