vendredi 18 octobre 2019

How to store array values in an environment variable in Postman

I am using a postman to automate apis.

Now I am using following request , lets say :-

{
  "customerId": ""
}

Where clientid is a dynamic variable whose value is substituted dynamically as 1 , 2, 3,4 so on.. I call this request multiple times using setNextRequest call in this eg lets say 10.

I want to store all these clientids coming in request into an environment array variable so I wrote a following pre-request script:-

ClientArray = pm.environment.get("ClientArray");

ClientArray.push(pm.environment.get("currentClientId"));

pm.environment.set("ClientArray","ClientArray");

Using the above scipts , it only stores one value in the output of ClientArray as opposed to all the 10 values coming in ClientId.

Could someone please advice how to achieve this.

Aucun commentaire:

Enregistrer un commentaire