Array is returned as comma separated string instead of array

I am trying to create request with a Pre-request script where I have an array. Then I am trying to use that array in a request. When I use the variable reference I get the array as a comma separated string of the elements. How can I get the array correctly?

Example: Pre-request script

pm.environment.set(“ambiances”, ambiances)

“ambiances_list”: “{{ambiances}}”


console.log(pm.environment.get(‘ambiances’)) :
(2) [true, false]

  1. 0: true
  2. 1: false


Hey @cryosat-participan11 :wave:

Welcome to the Postman Community! :postman:

You would probably need to use JSON.stringify here:

pm.environment.set(“ambiances”, JSON.stringify(ambiances));

And then in the body, you should remove the quotes around the variable syntax:

“ambiances_list”: {{ambiances}}

Thanks, this solved the problem

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.