Postman Array Data

Viewed 16

I am trying to pass Array value from Test to JSON Body in Postman. I have to pass one value at a time to JSON body(method Parameter) check JSON body Example.There should be problem in the code , could you please correct it.

"transaction": {
        "accounts": [
            {
                "bic": "MALE51MNZ",
                "iban": "DE85550501207",
                "instituteName": "Spardabank Mainz",
                "method": "",
                "type": "PAYMENT_BANK_TRANSFER"  
            }
        ],

var value=['BANK_COLLECTION','BANK_DEBIT_B2B','BANK_DEBIT_B2C','BANK_TRANSFER'];
var arrayLength= value.length;
var i=0;
var mybody = JSON.parse(pm.request.body.raw);
var ids=[];
console.log("davor")
console.log(value.length)

while (i<arrayLength)
{
    console.log("start")
    ids.push(value[i].accounts.method)
     i++;
    postman.setEnvironmentVariable("methodValue",JSON.stringify(ids));
  

var postRequest = {
    url: pm.environment.get("baseUrl") + "/",
    body: mybody,
    method: 'POST',
    header: {
        'Content-Type': 'application/json',
        'transaction': '5aa31bd4-ece3-448e-a853-962a19b11eb3',
        'Authorization': pm.environment.get("AuthKeyBearer")
    }
                };

    pm.sendRequest(postRequest, (error, myresponse) => {
        if (error) {
        console.log(error);
        }
  });
  console.log(i)
 
   }` 

when i send the request ,its not working ,Could you please help me

0 Answers
Related