How to deal with reading array of strings from csv , when the key needs array of input values

How to deal with reading values from csv , when the key needs array of input values
Eg :
my request body like this

{

“destinationCountry”: “FR”,

“postalCode”: “1001”,

“packages”: [{

  "size": {

    "width": 10,

    "height": 10,

    "length": 10

  },

  "volume": 1000,

  "weight": 50000,

  "value": 1

}],

“allowedCarriers”: [“A1”,“A2”],

“allowedwarehouses”: [“ABC”,“CDA”]

}

How to enter array of string values in allowedcarriers and allowedwarehouses after reading from the csv file

My CSVfile looks like this

Now i want to enter array of values in to carrier and warehouse values

Hi @varikuti ! Welcome to the Postman community. We’re glad you’re here.

In order to best help you, could you add some details to your post? Here are the posting guidelines. For even more specific help, sharing it in a public workspace could also be helpful.

Just to add to what @hannah.neil provided, to achieve your requirement do:

make the array as variable in your body:

“allowedCarriers”:{{array}},

Now in prerequest:

  pm.variables.set("array", JSON.stringify(data['carrier'].split("|")))
3 Likes

@praveendvd @hannah.neil Thanks a lot guys it is working perfectly fine. Again I really appreciate you inputs.

2 Likes

So glad it worked! Thanks for letting us know :rocket:

2 Likes