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

Hi @praveendvd @hannah.neil I have a request body look like:-
“ABC”: [
“a;a;local;wifi” , “a;a;local;wifi”, “a;a;local;wifi”
],

So i want to automate this by importing csv for the string values in this array ABC.

Please help me how to import multiple bulk data via CSV… Let me know the Postman changes and CSV file how to create. I’m using Excel and saving that as .csv

I’ve tried below solutions but it is only importing single value
I’ve made json file as:-
“ABC”: [
{{ABC}}
],
And I’ve passed in excel sheet saved as .csv where i passed column name “ABC” with multiple values in that column as :
ABC
“a;a;local;wifi”
“a;a;local;wifi”
“a;a;local;wifi”
“a;a;local;wifi”

Hence, I need a solution where each row value get imported in the same iteration in the same Array separated by comma like I’ve mentioned on the top.