How to get the value of key on mentioned json

var res = pm.response.json();

I need to assert multiple strings on response , in that process - i need to store code: AA in variable.
res.options[0].list[0] - it will reach till options>0>list>0

i need to go till options>0>list>0>0 - whats the snippet to reach there?res.options[0].list[0].[0] is not working.

@LokeshReddy219 Welcome to the community!!

Kindly provide the response body if possible.

Hey @LokeshReddy219

Could you just paste the raw response body, rather than an image of it please?

It makes it super difficult to reproduce things locally when you need to read and write out each character of that json response, from a picture. :joy:

I don’t really know the full context here but it looks like this could work:

res.options[0].list[0]["0"]

I don’t have the response body to prove this works so I haven’t run this to see the output.

1 Like

Here is the response body. i need to verify all these in my test. Kindly help me to do this.

{
  "options": [
    {
      "type": "COUNTRY_SUBDIVISION",
      "list": [
        [
          {
            "code": "AA",
            "name": "Armed Forces Americas (not Ca)"
          },
          {
            "code": "AE",
            "name": "Armed Forces Ca,eur,africa, Me"
          },
          {
            "code": "AK",
            "name": "Alaska"
          },
          {
            "code": "AL",
            "name": "Alabama"
          },
          {
            "code": "AP",
            "name": "Armed Forces Pacific"
          },
          {
            "code": "AR",
            "name": "Arkansas"
          },
          {
            "code": "AS",
            "name": "American Samoa"
          },
          {
            "code": "AZ",
            "name": "Arizona"
          },
          {
            "code": "CA",
            "name": "California"
          },
          {
            "code": "CO",
            "name": "Colorado"
          },
          {
            "code": "CT",
            "name": "Connecticut"
          },
          {
            "code": "DC",
            "name": "District Of Columbia"
          },
          {
            "code": "DE",
            "name": "Delaware"
          },
          {
            "code": "FL",
            "name": "Florida"
          },
          {
            "code": "FM",
            "name": "Micronesia, Federated States O"
          },
          {
            "code": "GA",
            "name": "Georgia"
          },
          {
            "code": "GU",
            "name": "Guam"
          },
          {
            "code": "HI",
            "name": "Hawaii"
          },
          {
            "code": "IA",
            "name": "Iowa"
          },
          {
            "code": "ID",
            "name": "Idaho"
          },
          {
            "code": "IL",
            "name": "Illinois"
          },
          {
            "code": "IN",
            "name": "Indiana"
          },
          {
            "code": "KS",
            "name": "Kansas"
          },
          {
            "code": "KY",
            "name": "Kentucky"
          },
          {
            "code": "LA",
            "name": "Louisiana"
          },
          {
            "code": "MA",
            "name": "Massachusetts"
          },
          {
            "code": "MD",
            "name": "Maryland"
          },
          {
            "code": "ME",
            "name": "Maine"
          },
          {
            "code": "MH",
            "name": "Marshall Islands"
          },
          {
            "code": "MI",
            "name": "Michigan"
          },
          {
            "code": "MN",
            "name": "Minnesota"
          },
          {
            "code": "MO",
            "name": "Missouri"
          },
          {
            "code": "MP",
            "name": "Northern Mariana Islands"
          },
          {
            "code": "MS",
            "name": "Mississippi"
          },
          {
            "code": "MT",
            "name": "Montana"
          },
          {
            "code": "NC",
            "name": "North Carolina"
          },
          {
            "code": "ND",
            "name": "North Dakota"
          },
          {
            "code": "NE",
            "name": "Nebraska"
          },
          {
            "code": "NH",
            "name": "New Hampshire"
          },
          {
            "code": "NJ",
            "name": "New Jersey"
          },
          {
            "code": "NM",
            "name": "New Mexico"
          },
          {
            "code": "NV",
            "name": "Nevada"
          },
          {
            "code": "NY",
            "name": "New York"
          },
          {
            "code": "OH",
            "name": "Ohio"
          },
          {
            "code": "OK",
            "name": "Oklahoma"
          },
          {
            "code": "OR",
            "name": "Oregon"
          },
          {
            "code": "PA",
            "name": "Pennsylvania"
          },
          {
            "code": "PR",
            "name": "Puerto Rico"
          },
          {
            "code": "PW",
            "name": "Palau"
          },
          {
            "code": "RI",
            "name": "Rhode Island"
          },
          {
            "code": "SC",
            "name": "South Carolina"
          },
          {
            "code": "SD",
            "name": "South Dakota"
          },
          {
            "code": "TN",
            "name": "Tennessee"
          },
          {
            "code": "TX",
            "name": "Texas"
          },
          {
            "code": "UT",
            "name": "Utah"
          },
          {
            "code": "VA",
            "name": "Virginia"
          },
          {
            "code": "VI",
            "name": "Virgin Islands"
          },
          {
            "code": "VT",
            "name": "Vermont"
          },
          {
            "code": "WA",
            "name": "Washington"
          },
          {
            "code": "WI",
            "name": "Wisconsin"
          },
          {
            "code": "WV",
            "name": "West Virginia"
          },
          {
            "code": "WY",
            "name": "Wyoming"
          }
        ]
      ]
    },
    {
      "type": "COUNTRY",
      "list": [
        [
          {
            "phoneCode": "376",
            "code": "AD",
            "name": "Andorra"
          },
          {
            "phoneCode": "971",
            "code": "AE",
            "name": "United Arab Emirates"
          },
          {
            "phoneCode": "93",
            "code": "AF",
            "name": "Afghanistan"
          },
          {
            "phoneCode": "1",
            "code": "AG",
            "name": "Antigua"
          },
          {
            "phoneCode": "1",
            "code": "AI",
            "name": "Anguilla"
          },
          {
            "phoneCode": "355",
            "code": "AL",
            "name": "Albania"
          },
          {
            "phoneCode": "374",
            "code": "AM",
            "name": "Armenia"
          },
          {
            "phoneCode": "1",
            "code": "AN",
            "name": "Netherlands Antilles"
          },
          {
            "phoneCode": "244",
            "code": "AO",
            "name": "Angola"
          },
          {
            "phoneCode": "54",
            "code": "AR",
            "name": "Argentina"
          },
          {
            "phoneCode": "43",
            "code": "AT",
            "name": "Austria"
          },
          {
            "phoneCode": "61",
            "code": "AU",
            "name": "Australia"
          },
          {
            "phoneCode": "297",
            "code": "AW",
            "name": "Aruba"
          },
          {
            "phoneCode": "994",
            "code": "AZ",
            "name": "Azerbaijan"
          },
          {
            "phoneCode": "387",
            "code": "BA",
            "name": "Bosnia And Herzegovina"
          },
          {
            "phoneCode": "1",
            "code": "BB",
            "name": "Barbados"
          },
          {
            "phoneCode": "880",
            "code": "BD",
            "name": "Bangladesh"
          },
          {
            "phoneCode": "32",
            "code": "BE",
            "name": "Belgium"
          },
          {
            "phoneCode": "226",
            "code": "BF",
            "name": "Burkina Faso"
          },
          {
            "phoneCode": "359",
            "code": "BG",
            "name": "Bulgaria"
          },
          {
            "phoneCode": "973",
            "code": "BH",
            "name": "Bahrain"
          },
          {
            "phoneCode": "257",
            "code": "BI",
            "name": "Burundi"
          },
          {
            "phoneCode": "229",
            "code": "BJ",
            "name": "Benin"
          },
          {
            "phoneCode": "1",
            "code": "BM",
            "name": "Bermuda"
          },
          {
            "phoneCode": "673",
            "code": "BN",
            "name": "Brunei"
          },
          {
            "phoneCode": "591",
            "code": "BO",
            "name": "Bolivia"
          },
          {
            "phoneCode": "55",
            "code": "BR",
            "name": "Brazil"
          },
          {
            "phoneCode": "1",
            "code": "BS",
            "name": "Bahamas"
          },
          {
            "phoneCode": "975",
            "code": "BT",
            "name": "Bhutan"
          },
          {
            "phoneCode": "267",
            "code": "BW",
            "name": "Botswana"
          },
          {
            "phoneCode": "375",
            "code": "BY",
            "name": "Belarus"
          },
          {
            "phoneCode": "501",
            "code": "BZ",
            "name": "Belize"
          },
          {
            "phoneCode": "1",
            "code": "CA",
            "name": "Canada"
          },
          {
            "phoneCode": "61",
            "code": "CC",
            "name": "Cocos (keeling) Islands"
          },
          {
            "phoneCode": "243",
            "code": "CD",
            "name": "Dem Rep Of The Congo"
          },
          {
            "phoneCode": "236",
            "code": "CF",
            "name": "Central African Republic"
          },
          {
            "phoneCode": "242",
            "code": "CG",
            "name": "Congo"
          },
          {
            "phoneCode": "41",
            "code": "CH",
            "name": "Switzerland"
          },
          {
            "phoneCode": "225",
            "code": "CI",
            "name": "Ivory Coast"
          },
          {
            "phoneCode": "682",
            "code": "CK",
            "name": "Cook Islands"
          },
          {
            "phoneCode": "56",
            "code": "CL",
            "name": "Chile"
          },
          {
            "phoneCode": "237",
            "code": "CM",
            "name": "Cameroon"
          },
          {
            "phoneCode": "86",
            "code": "CN",
            "name": "China"
          },
          {
            "phoneCode": "57",
            "code": "CO",
            "name": "Colombia"
          },
          {
            "phoneCode": "506",
            "code": "CR",
            "name": "Costa Rica"
          },
          {
            "phoneCode": "238",
            "code": "CV",
            "name": "Cape Verde"
          },
          {
            "phoneCode": "357",
            "code": "CY",
            "name": "Cyprus"
          },
          {
            "phoneCode": "420",
            "code": "CZ",
            "name": "Czech Republic"
          },
          {
            "phoneCode": "49",
            "code": "DE",
            "name": "Germany"
          },
          {
            "phoneCode": "253",
            "code": "DJ",
            "name": "Djibouti"
          },
          {
            "phoneCode": "45",
            "code": "DK",
            "name": "Denmark"
          },
          {
            "phoneCode": "1",
            "code": "DM",
            "name": "Dominica"
          },
          {
            "phoneCode": "1",
            "code": "DO",
            "name": "Dominican Republic"
          },
          {
            "phoneCode": "213",
            "code": "DZ",
            "name": "Algeria"
          },
          {
            "phoneCode": "593",
            "code": "EC",
            "name": "Ecuador"
          },
          {
            "phoneCode": "372",
            "code": "EE",
            "name": "Estonia"
          },
          {
            "phoneCode": "20",
            "code": "EG",
            "name": "Egypt"
          },
          {
            "phoneCode": "212",
            "code": "EH",
            "name": "Western Sahara"
          },
          {
            "phoneCode": "291",
            "code": "ER",
            "name": "Eritrea"
          },
          {
            "phoneCode": "34",
            "code": "ES",
            "name": "Spain"
          },
          {
            "phoneCode": "251",
            "code": "ET",
            "name": "Ethiopia"
          },
          {
            "phoneCode": "358",
            "code": "FI",
            "name": "Finland"
          },
          {
            "phoneCode": "679",
            "code": "FJ",
            "name": "Fiji"
          },
          {
            "phoneCode": "500",
            "code": "FK",
            "name": "Falkland Islands"
          },
          {
            "phoneCode": "298",
            "code": "FO",
            "name": "Faroe Islands"
          },
          {
            "phoneCode": "33",
            "code": "FR",
            "name": "France"
          },
          {
            "phoneCode": "241",
            "code": "GA",
            "name": "Gabon"
          },
          {
            "phoneCode": "44",
            "code": "GB",
            "name": "United Kingdom"
          },
          {
            "phoneCode": "1",
            "code": "GD",
            "name": "Grenada"
          },
          {
            "phoneCode": "995",
            "code": "GE",
            "name": "Georgia"
          },
          {
            "phoneCode": "594",
            "code": "GF",
            "name": "French Guiana"
          },
          {
            "phoneCode": "233",
            "code": "GH",
            "name": "Ghana"
          },
          {
            "phoneCode": "350",
            "code": "GI",
            "name": "Gibraltar"
          },
          {
            "phoneCode": "299",
            "code": "GL",
            "name": "Greenland"
          },
          {
            "phoneCode": "220",
            "code": "GM",
            "name": "Gambia"
          },
          {
            "phoneCode": "224",
            "code": "GN",
            "name": "Guinea"
          },
          {
            "phoneCode": "590",
            "code": "GP",
            "name": "Guadeloupe"
          },
          {
            "phoneCode": "240",
            "code": "GQ",
            "name": "Equatorial Guinea"
          },
          {
            "phoneCode": "30",
            "code": "GR",
            "name": "Greece"
          },
          {
            "phoneCode": "502",
            "code": "GT",
            "name": "Guatemala"
          },
          {
            "phoneCode": "245",
            "code": "GW",
            "name": "Guinea-bissau"
          },
          {
            "phoneCode": "592",
            "code": "GY",
            "name": "Guyana"
          },
          {
            "phoneCode": "852",
            "code": "HK",
            "name": "Hong Kong"
          },
          {
            "phoneCode": "504",
            "code": "HN",
            "name": "Honduras"
          },
          {
            "phoneCode": "385",
            "code": "HR",
            "name": "Croatia"
          },
          {
            "phoneCode": "509",
            "code": "HT",
            "name": "Haiti"
          },
          {
            "phoneCode": "36",
            "code": "HU",
            "name": "Hungary"
          },
          {
            "phoneCode": "62",
            "code": "ID",
            "name": "Indonesia"
          },
          {
            "phoneCode": "353",
            "code": "IE",
            "name": "Ireland"
          },
          {
            "phoneCode": "972",
            "code": "IL",
            "name": "Israel"
          },
          {
            "phoneCode": "91",
            "code": "IN",
            "name": "India"
          },
          {
            "phoneCode": "964",
            "code": "IQ",
            "name": "Iraq"
          },
          {
            "phoneCode": "354",
            "code": "IS",
            "name": "Iceland"
          },
          {
            "phoneCode": "39",
            "code": "IT",
            "name": "Italy"
          },
          {
            "phoneCode": "1",
            "code": "JM",
            "name": "Jamaica"
          },
          {
            "phoneCode": "962",
            "code": "JO",
            "name": "Jordan"
          },
          {
            "phoneCode": "81",
            "code": "JP",
            "name": "Japan"
          },
          {
            "phoneCode": "254",
            "code": "KE",
            "name": "Kenya"
          },
          {
            "phoneCode": "996",
            "code": "KG",
            "name": "Kyrgyzstan"
          },
          {
            "phoneCode": "855",
            "code": "KH",
            "name": "Cambodia"
          },
          {
            "phoneCode": "686",
            "code": "KI",
            "name": "Kiribati"
          },
          {
            "phoneCode": "269",
            "code": "KM",
            "name": "Comoros"
          },
          {
            "phoneCode": "1",
            "code": "KN",
            "name": "Saint Kitts And Nevis"
          },
          {
            "phoneCode": "82",
            "code": "KR",
            "name": "South Korea"
          },
          {
            "phoneCode": "965",
            "code": "KW",
            "name": "Kuwait"
          },
          {
            "phoneCode": "1",
            "code": "KY",
            "name": "Cayman Islands"
          },
          {
            "phoneCode": "7",
            "code": "KZ",
            "name": "Kazakhstan"
          },
          {
            "phoneCode": "856",
            "code": "LA",
            "name": "Laos"
          },
          {
            "phoneCode": "961",
            "code": "LB",
            "name": "Lebanon"
          },
          {
            "phoneCode": "1",
            "code": "LC",
            "name": "Saint Lucia"
          },
          {
            "phoneCode": "423",
            "code": "LI",
            "name": "Liechtenstein"
          },
          {
            "phoneCode": "94",
            "code": "LK",
            "name": "Sri Lanka"
          },
          {
            "phoneCode": "231",
            "code": "LR",
            "name": "Liberia"
          },
          {
            "phoneCode": "266",
            "code": "LS",
            "name": "Lesotho"
          },
          {
            "phoneCode": "370",
            "code": "LT",
            "name": "Lithuania"
          },
          {
            "phoneCode": "352",
            "code": "LU",
            "name": "Luxembourg"
          },
          {
            "phoneCode": "371",
            "code": "LV",
            "name": "Latvia"
          },
          {
            "phoneCode": "218",
            "code": "LY",
            "name": "Libya"
          },
          {
            "phoneCode": "212",
            "code": "MA",
            "name": "Morocco"
          },
          {
            "phoneCode": "377",
            "code": "MC",
            "name": "Monaco"
          },
          {
            "phoneCode": "373",
            "code": "MD",
            "name": "Moldova"
          },
          {
            "phoneCode": "382",
            "code": "ME",
            "name": "Montenegro"
          },
          {
            "phoneCode": "261",
            "code": "MG",
            "name": "Madagascar"
          },
          {
            "phoneCode": "389",
            "code": "MK",
            "name": "Macedonia"
          },
          {
            "phoneCode": "223",
            "code": "ML",
            "name": "Mali"
          },
          {
            "phoneCode": "95",
            "code": "MM",
            "name": "Myanmar"
          },
          {
            "phoneCode": "976",
            "code": "MN",
            "name": "Mongolia"
          },
          {
            "phoneCode": "853",
            "code": "MO",
            "name": "Macau"
          },
          {
            "phoneCode": "596",
            "code": "MQ",
            "name": "Martinique"
          },
          {
            "phoneCode": "222",
            "code": "MR",
            "name": "Mauritania"
          },
          {
            "phoneCode": "1",
            "code": "MS",
            "name": "Montserrat"
          },
          {
            "phoneCode": "356",
            "code": "MT",
            "name": "Malta"
          },
          {
            "phoneCode": "230",
            "code": "MU",
            "name": "Mauritius"
          },
          {
            "phoneCode": "960",
            "code": "MV",
            "name": "Maldives"
          },
          {
            "phoneCode": "265",
            "code": "MW",
            "name": "Malawi"
          },
          {
            "phoneCode": "52",
            "code": "MX",
            "name": "Mexico"
          },
          {
            "phoneCode": "60",
            "code": "MY",
            "name": "Malaysia"
          },
          {
            "phoneCode": "258",
            "code": "MZ",
            "name": "Mozambique"
          },
          {
            "phoneCode": "264",
            "code": "NA",
            "name": "Namibia"
          },
          {
            "phoneCode": "687",
            "code": "NC",
            "name": "New Caledonia"
          },
          {
            "phoneCode": "227",
            "code": "NE",
            "name": "Niger"
          },
          {
            "phoneCode": "672",
            "code": "NF",
            "name": "Norfolk Island"
          },
          {
            "phoneCode": "234",
            "code": "NG",
            "name": "Nigeria"
          },
          {
            "phoneCode": "505",
            "code": "NI",
            "name": "Nicaragua"
          },
          {
            "phoneCode": "31",
            "code": "NL",
            "name": "Netherlands"
          },
          {
            "phoneCode": "47",
            "code": "NO",
            "name": "Norway"
          },
          {
            "phoneCode": "977",
            "code": "NP",
            "name": "Nepal"
          },
          {
            "phoneCode": "674",
            "code": "NR",
            "name": "Nauru"
          },
          {
            "phoneCode": "683",
            "code": "NU",
            "name": "Niue"
          },
          {
            "phoneCode": "64",
            "code": "NZ",
            "name": "New Zealand"
          },
          {
            "phoneCode": "968",
            "code": "OM",
            "name": "Oman"
          },
          {
            "phoneCode": "507",
            "code": "PA",
            "name": "Panama"
          },
          {
            "phoneCode": "51",
            "code": "PE",
            "name": "Peru"
          },
          {
            "phoneCode": "689",
            "code": "PF",
            "name": "French Polynesia"
          },
          {
            "phoneCode": "675",
            "code": "PG",
            "name": "Papua New Guinea"
          },
          {
            "phoneCode": "63",
            "code": "PH",
            "name": "Philippines"
          },
          {
            "phoneCode": "92",
            "code": "PK",
            "name": "Pakistan"
          },
          {
            "phoneCode": "48",
            "code": "PL",
            "name": "Poland"
          },
          {
            "phoneCode": "508",
            "code": "PM",
            "name": "St. Pierre And Miquelon"
          },
          {
            "phoneCode": "351",
            "code": "PT",
            "name": "Portugal"
          },
          {
            "phoneCode": "595",
            "code": "PY",
            "name": "Paraguay"
          },
          {
            "phoneCode": "974",
            "code": "QA",
            "name": "Qatar"
          },
          {
            "phoneCode": "262",
            "code": "RE",
            "name": "Reunion Islands"
          },
          {
            "phoneCode": "40",
            "code": "RO",
            "name": "Romania"
          },
          {
            "phoneCode": "381",
            "code": "RS",
            "name": "Serbia"
          },
          {
            "phoneCode": "7",
            "code": "RU",
            "name": "Russia"
          },
          {
            "phoneCode": "250",
            "code": "RW",
            "name": "Rwanda"
          },
          {
            "phoneCode": "966",
            "code": "SA",
            "name": "Saudi Arabia"
          },
          {
            "phoneCode": "677",
            "code": "SB",
            "name": "Soloman Islands"
          },
          {
            "phoneCode": "248",
            "code": "SC",
            "name": "Seychelles"
          },
          {
            "phoneCode": "46",
            "code": "SE",
            "name": "Sweden"
          },
          {
            "phoneCode": "65",
            "code": "SG",
            "name": "Singapore"
          },
          {
            "phoneCode": "290",
            "code": "SH",
            "name": "St. Helena"
          },
          {
            "phoneCode": "386",
            "code": "SI",
            "name": "Slovenia"
          },
          {
            "phoneCode": "421",
            "code": "SK",
            "name": "Slovakia"
          },
          {
            "phoneCode": "232",
            "code": "SL",
            "name": "Sierra Leone"
          },
          {
            "phoneCode": "378",
            "code": "SM",
            "name": "San Marino"
          },
          {
            "phoneCode": "221",
            "code": "SN",
            "name": "Senegal"
          },
          {
            "phoneCode": "252",
            "code": "SO",
            "name": "Somalia"
          },
          {
            "phoneCode": "597",
            "code": "SR",
            "name": "Suriname"
          },
          {
            "phoneCode": "239",
            "code": "ST",
            "name": "Sao Tome And Principe"
          },
          {
            "phoneCode": "503",
            "code": "SV",
            "name": "El Salvador"
          },
          {
            "phoneCode": "268",
            "code": "SZ",
            "name": "Swaziland"
          },
          {
            "phoneCode": "1",
            "code": "TC",
            "name": "Turks And Caicos Islands"
          },
          {
            "phoneCode": "235",
            "code": "TD",
            "name": "Chad"
          },
          {
            "phoneCode": "228",
            "code": "TG",
            "name": "Togo"
          },
          {
            "phoneCode": "66",
            "code": "TH",
            "name": "Thailand"
          },
          {
            "phoneCode": "992",
            "code": "TJ",
            "name": "Tajikistan"
          },
          {
            "phoneCode": "690",
            "code": "TK",
            "name": "Tokelau"
          },
          {
            "phoneCode": "670",
            "code": "TL",
            "name": "Timor-leste"
          },
          {
            "phoneCode": "993",
            "code": "TM",
            "name": "Turkmenistan"
          },
          {
            "phoneCode": "216",
            "code": "TN",
            "name": "Tunisia"
          },
          {
            "phoneCode": "676",
            "code": "TO",
            "name": "Tonga"
          },
          {
            "phoneCode": "90",
            "code": "TR",
            "name": "Turkey"
          },
          {
            "phoneCode": "1",
            "code": "TT",
            "name": "Trinidad And Tobago"
          },
          {
            "phoneCode": "688",
            "code": "TV",
            "name": "Tuvalu"
          },
          {
            "phoneCode": "886",
            "code": "TW",
            "name": "Taiwan"
          },
          {
            "phoneCode": "255",
            "code": "TZ",
            "name": "Tanzania"
          },
          {
            "phoneCode": "380",
            "code": "UA",
            "name": "Ukraine"
          },
          {
            "phoneCode": "256",
            "code": "UG",
            "name": "Uganda"
          },
          {
            "phoneCode": "1",
            "code": "US",
            "name": "United States"
          },
          {
            "phoneCode": "598",
            "code": "UY",
            "name": "Uruguay"
          },
          {
            "phoneCode": "998",
            "code": "UZ",
            "name": "Uzbekistan"
          },
          {
            "phoneCode": "39",
            "code": "VA",
            "name": "Holy See (vatican City)"
          },
          {
            "phoneCode": "1",
            "code": "VC",
            "name": "Saint Vincent And The Grenadines"
          },
          {
            "phoneCode": "58",
            "code": "VE",
            "name": "Venezuela"
          },
          {
            "phoneCode": "1",
            "code": "VG",
            "name": "British Virgin Islands"
          },
          {
            "phoneCode": "84",
            "code": "VN",
            "name": "Vietnam"
          },
          {
            "phoneCode": "678",
            "code": "VU",
            "name": "Vanuatu"
          },
          {
            "phoneCode": "681",
            "code": "WF",
            "name": "Wallis And Futuna"
          },
          {
            "phoneCode": "685",
            "code": "WS",
            "name": "Samoa"
          },
          {
            "phoneCode": "967",
            "code": "YE",
            "name": "Yemen"
          },
          {
            "phoneCode": "262",
            "code": "YT",
            "name": "Mayotte"
          },
          {
            "phoneCode": "27",
            "code": "ZA",
            "name": "South Africa"
          },
          {
            "phoneCode": "260",
            "code": "ZM",
            "name": "Zambia"
          },
          {
            "phoneCode": "263",
            "code": "ZW",
            "name": "Zimbabwe"
          }
        ]
      ]
    }
  ],
  "errors": [
    {
      "code": "11111",
      "message": "Invalid Client ID"
    }
  ],
  "status": [
    "SUCCESS"
  ]
}

Thanks for the response Bprucilla. here is the response body.

{
“options”: [
{
“type”: “COUNTRY_SUBDIVISION”,
“list”: [
[
{
“code”: “AA”,
“name”: “Armed Forces Americas (not Ca)”
},
{
“code”: “AE”,
“name”: “Armed Forces Ca,eur,africa, Me”
},
{
“code”: “AK”,
“name”: “Alaska”
},
{
“code”: “AL”,
“name”: “Alabama”
},
{
“code”: “AP”,
“name”: “Armed Forces Pacific”
},
{
“code”: “AR”,
“name”: “Arkansas”
},
{
“code”: “AS”,
“name”: “American Samoa”
},
{
“code”: “AZ”,
“name”: “Arizona”
},
{
“code”: “CA”,
“name”: “California”
},
{
“code”: “CO”,
“name”: “Colorado”
},
{
“code”: “CT”,
“name”: “Connecticut”
},
{
“code”: “DC”,
“name”: “District Of Columbia”
},
{
“code”: “DE”,
“name”: “Delaware”
},
{
“code”: “FL”,
“name”: “Florida”
},
{
“code”: “FM”,
“name”: “Micronesia, Federated States O”
},
{
“code”: “GA”,
“name”: “Georgia”
},
{
“code”: “GU”,
“name”: “Guam”
},
{
“code”: “HI”,
“name”: “Hawaii”
},
{
“code”: “IA”,
“name”: “Iowa”
},
{
“code”: “ID”,
“name”: “Idaho”
},
{
“code”: “IL”,
“name”: “Illinois”
},
{
“code”: “IN”,
“name”: “Indiana”
},
{
“code”: “KS”,
“name”: “Kansas”
},
{
“code”: “KY”,
“name”: “Kentucky”
},
{
“code”: “LA”,
“name”: “Louisiana”
},
{
“code”: “MA”,
“name”: “Massachusetts”
},
{
“code”: “MD”,
“name”: “Maryland”
},
{
“code”: “ME”,
“name”: “Maine”
},
{
“code”: “MH”,
“name”: “Marshall Islands”
},
{
“code”: “MI”,
“name”: “Michigan”
},
{
“code”: “MN”,
“name”: “Minnesota”
},
{
“code”: “MO”,
“name”: “Missouri”
},
{
“code”: “MP”,
“name”: “Northern Mariana Islands”
},
{
“code”: “MS”,
“name”: “Mississippi”
},
{
“code”: “MT”,
“name”: “Montana”
},
{
“code”: “NC”,
“name”: “North Carolina”
},
{
“code”: “ND”,
“name”: “North Dakota”
},
{
“code”: “NE”,
“name”: “Nebraska”
},
{
“code”: “NH”,
“name”: “New Hampshire”
},
{
“code”: “NJ”,
“name”: “New Jersey”
},
{
“code”: “NM”,
“name”: “New Mexico”
},
{
“code”: “NV”,
“name”: “Nevada”
},
{
“code”: “NY”,
“name”: “New York”
},
{
“code”: “OH”,
“name”: “Ohio”
},
{
“code”: “OK”,
“name”: “Oklahoma”
},
{
“code”: “OR”,
“name”: “Oregon”
},
{
“code”: “PA”,
“name”: “Pennsylvania”
},
{
“code”: “PR”,
“name”: “Puerto Rico”
},
{
“code”: “PW”,
“name”: “Palau”
},
{
“code”: “RI”,
“name”: “Rhode Island”
},
{
“code”: “SC”,
“name”: “South Carolina”
},
{
“code”: “SD”,
“name”: “South Dakota”
},
{
“code”: “TN”,
“name”: “Tennessee”
},
{
“code”: “TX”,
“name”: “Texas”
},
{
“code”: “UT”,
“name”: “Utah”
},
{
“code”: “VA”,
“name”: “Virginia”
},
{
“code”: “VI”,
“name”: “Virgin Islands”
},
{
“code”: “VT”,
“name”: “Vermont”
},
{
“code”: “WA”,
“name”: “Washington”
},
{
“code”: “WI”,
“name”: “Wisconsin”
},
{
“code”: “WV”,
“name”: “West Virginia”
},
{
“code”: “WY”,
“name”: “Wyoming”
}
]
]
},
{
“type”: “COUNTRY”,
“list”: [
[
{
“phoneCode”: “376”,
“code”: “AD”,
“name”: “Andorra”
},
{
“phoneCode”: “971”,
“code”: “AE”,
“name”: “United Arab Emirates”
},
{
“phoneCode”: “93”,
“code”: “AF”,
“name”: “Afghanistan”
},
{
“phoneCode”: “1”,
“code”: “AG”,
“name”: “Antigua”
},
{
“phoneCode”: “1”,
“code”: “AI”,
“name”: “Anguilla”
},
{
“phoneCode”: “355”,
“code”: “AL”,
“name”: “Albania”
},
{
“phoneCode”: “374”,
“code”: “AM”,
“name”: “Armenia”
},
{
“phoneCode”: “1”,
“code”: “AN”,
“name”: “Netherlands Antilles”
},
{
“phoneCode”: “244”,
“code”: “AO”,
“name”: “Angola”
},
{
“phoneCode”: “54”,
“code”: “AR”,
“name”: “Argentina”
},
{
“phoneCode”: “43”,
“code”: “AT”,
“name”: “Austria”
},
{
“phoneCode”: “61”,
“code”: “AU”,
“name”: “Australia”
},
{
“phoneCode”: “297”,
“code”: “AW”,
“name”: “Aruba”
},
{
“phoneCode”: “994”,
“code”: “AZ”,
“name”: “Azerbaijan”
},
{
“phoneCode”: “387”,
“code”: “BA”,
“name”: “Bosnia And Herzegovina”
},
{
“phoneCode”: “1”,
“code”: “BB”,
“name”: “Barbados”
},
{
“phoneCode”: “880”,
“code”: “BD”,
“name”: “Bangladesh”
},
{
“phoneCode”: “32”,
“code”: “BE”,
“name”: “Belgium”
},
{
“phoneCode”: “226”,
“code”: “BF”,
“name”: “Burkina Faso”
},
{
“phoneCode”: “359”,
“code”: “BG”,
“name”: “Bulgaria”
},
{
“phoneCode”: “973”,
“code”: “BH”,
“name”: “Bahrain”
},
{
“phoneCode”: “257”,
“code”: “BI”,
“name”: “Burundi”
},
{
“phoneCode”: “229”,
“code”: “BJ”,
“name”: “Benin”
},
{
“phoneCode”: “1”,
“code”: “BM”,
“name”: “Bermuda”
},
{
“phoneCode”: “673”,
“code”: “BN”,
“name”: “Brunei”
},
{
“phoneCode”: “591”,
“code”: “BO”,
“name”: “Bolivia”
},
{
“phoneCode”: “55”,
“code”: “BR”,
“name”: “Brazil”
},
{
“phoneCode”: “1”,
“code”: “BS”,
“name”: “Bahamas”
},
{
“phoneCode”: “975”,
“code”: “BT”,
“name”: “Bhutan”
},
{
“phoneCode”: “267”,
“code”: “BW”,
“name”: “Botswana”
},
{
“phoneCode”: “375”,
“code”: “BY”,
“name”: “Belarus”
},
{
“phoneCode”: “501”,
“code”: “BZ”,
“name”: “Belize”
},
{
“phoneCode”: “1”,
“code”: “CA”,
“name”: “Canada”
},
{
“phoneCode”: “61”,
“code”: “CC”,
“name”: “Cocos (keeling) Islands”
},
{
“phoneCode”: “243”,
“code”: “CD”,
“name”: “Dem Rep Of The Congo”
},
{
“phoneCode”: “236”,
“code”: “CF”,
“name”: “Central African Republic”
},
{
“phoneCode”: “242”,
“code”: “CG”,
“name”: “Congo”
},
{
“phoneCode”: “41”,
“code”: “CH”,
“name”: “Switzerland”
},
{
“phoneCode”: “225”,
“code”: “CI”,
“name”: “Ivory Coast”
},
{
“phoneCode”: “682”,
“code”: “CK”,
“name”: “Cook Islands”
},
{
“phoneCode”: “56”,
“code”: “CL”,
“name”: “Chile”
},
{
“phoneCode”: “237”,
“code”: “CM”,
“name”: “Cameroon”
},
{
“phoneCode”: “86”,
“code”: “CN”,
“name”: “China”
},
{
“phoneCode”: “57”,
“code”: “CO”,
“name”: “Colombia”
},
{
“phoneCode”: “506”,
“code”: “CR”,
“name”: “Costa Rica”
},
{
“phoneCode”: “238”,
“code”: “CV”,
“name”: “Cape Verde”
},
{
“phoneCode”: “357”,
“code”: “CY”,
“name”: “Cyprus”
},
{
“phoneCode”: “420”,
“code”: “CZ”,
“name”: “Czech Republic”
},
{
“phoneCode”: “49”,
“code”: “DE”,
“name”: “Germany”
},
{
“phoneCode”: “253”,
“code”: “DJ”,
“name”: “Djibouti”
},
{
“phoneCode”: “45”,
“code”: “DK”,
“name”: “Denmark”
},
{
“phoneCode”: “1”,
“code”: “DM”,
“name”: “Dominica”
},
{
“phoneCode”: “1”,
“code”: “DO”,
“name”: “Dominican Republic”
},
{
“phoneCode”: “213”,
“code”: “DZ”,
“name”: “Algeria”
},
{
“phoneCode”: “593”,
“code”: “EC”,
“name”: “Ecuador”
},
{
“phoneCode”: “372”,
“code”: “EE”,
“name”: “Estonia”
},
{
“phoneCode”: “20”,
“code”: “EG”,
“name”: “Egypt”
},
{
“phoneCode”: “212”,
“code”: “EH”,
“name”: “Western Sahara”
},
{
“phoneCode”: “291”,
“code”: “ER”,
“name”: “Eritrea”
},
{
“phoneCode”: “34”,
“code”: “ES”,
“name”: “Spain”
},
{
“phoneCode”: “251”,
“code”: “ET”,
“name”: “Ethiopia”
},
{
“phoneCode”: “358”,
“code”: “FI”,
“name”: “Finland”
},
{
“phoneCode”: “679”,
“code”: “FJ”,
“name”: “Fiji”
},
{
“phoneCode”: “500”,
“code”: “FK”,
“name”: “Falkland Islands”
},
{
“phoneCode”: “298”,
“code”: “FO”,
“name”: “Faroe Islands”
},
{
“phoneCode”: “33”,
“code”: “FR”,
“name”: “France”
},
{
“phoneCode”: “241”,
“code”: “GA”,
“name”: “Gabon”
},
{
“phoneCode”: “44”,
“code”: “GB”,
“name”: “United Kingdom”
},
{
“phoneCode”: “1”,
“code”: “GD”,
“name”: “Grenada”
},
{
“phoneCode”: “995”,
“code”: “GE”,
“name”: “Georgia”
},
{
“phoneCode”: “594”,
“code”: “GF”,
“name”: “French Guiana”
},
{
“phoneCode”: “233”,
“code”: “GH”,
“name”: “Ghana”
},
{
“phoneCode”: “350”,
“code”: “GI”,
“name”: “Gibraltar”
},
{
“phoneCode”: “299”,
“code”: “GL”,
“name”: “Greenland”
},
{
“phoneCode”: “220”,
“code”: “GM”,
“name”: “Gambia”
},
{
“phoneCode”: “224”,
“code”: “GN”,
“name”: “Guinea”
},
{
“phoneCode”: “590”,
“code”: “GP”,
“name”: “Guadeloupe”
},
{
“phoneCode”: “240”,
“code”: “GQ”,
“name”: “Equatorial Guinea”
},
{
“phoneCode”: “30”,
“code”: “GR”,
“name”: “Greece”
},
{
“phoneCode”: “502”,
“code”: “GT”,
“name”: “Guatemala”
},
{
“phoneCode”: “245”,
“code”: “GW”,
“name”: “Guinea-bissau”
},
{
“phoneCode”: “592”,
“code”: “GY”,
“name”: “Guyana”
},
{
“phoneCode”: “852”,
“code”: “HK”,
“name”: “Hong Kong”
},
{
“phoneCode”: “504”,
“code”: “HN”,
“name”: “Honduras”
},
{
“phoneCode”: “385”,
“code”: “HR”,
“name”: “Croatia”
},
{
“phoneCode”: “509”,
“code”: “HT”,
“name”: “Haiti”
},
{
“phoneCode”: “36”,
“code”: “HU”,
“name”: “Hungary”
},
{
“phoneCode”: “62”,
“code”: “ID”,
“name”: “Indonesia”
},
{
“phoneCode”: “353”,
“code”: “IE”,
“name”: “Ireland”
},
{
“phoneCode”: “972”,
“code”: “IL”,
“name”: “Israel”
},
{
“phoneCode”: “91”,
“code”: “IN”,
“name”: “India”
},
{
“phoneCode”: “964”,
“code”: “IQ”,
“name”: “Iraq”
},
{
“phoneCode”: “354”,
“code”: “IS”,
“name”: “Iceland”
},
{
“phoneCode”: “39”,
“code”: “IT”,
“name”: “Italy”
},
{
“phoneCode”: “1”,
“code”: “JM”,
“name”: “Jamaica”
},
{
“phoneCode”: “962”,
“code”: “JO”,
“name”: “Jordan”
},
{
“phoneCode”: “81”,
“code”: “JP”,
“name”: “Japan”
},
{
“phoneCode”: “254”,
“code”: “KE”,
“name”: “Kenya”
},
{
“phoneCode”: “996”,
“code”: “KG”,
“name”: “Kyrgyzstan”
},
{
“phoneCode”: “855”,
“code”: “KH”,
“name”: “Cambodia”
},
{
“phoneCode”: “686”,
“code”: “KI”,
“name”: “Kiribati”
},
{
“phoneCode”: “269”,
“code”: “KM”,
“name”: “Comoros”
},
{
“phoneCode”: “1”,
“code”: “KN”,
“name”: “Saint Kitts And Nevis”
},
{
“phoneCode”: “82”,
“code”: “KR”,
“name”: “South Korea”
},
{
“phoneCode”: “965”,
“code”: “KW”,
“name”: “Kuwait”
},
{
“phoneCode”: “1”,
“code”: “KY”,
“name”: “Cayman Islands”
},
{
“phoneCode”: “7”,
“code”: “KZ”,
“name”: “Kazakhstan”
},
{
“phoneCode”: “856”,
“code”: “LA”,
“name”: “Laos”
},
{
“phoneCode”: “961”,
“code”: “LB”,
“name”: “Lebanon”
},
{
“phoneCode”: “1”,
“code”: “LC”,
“name”: “Saint Lucia”
},
{
“phoneCode”: “423”,
“code”: “LI”,
“name”: “Liechtenstein”
},
{
“phoneCode”: “94”,
“code”: “LK”,
“name”: “Sri Lanka”
},
{
“phoneCode”: “231”,
“code”: “LR”,
“name”: “Liberia”
},
{
“phoneCode”: “266”,
“code”: “LS”,
“name”: “Lesotho”
},
{
“phoneCode”: “370”,
“code”: “LT”,
“name”: “Lithuania”
},
{
“phoneCode”: “352”,
“code”: “LU”,
“name”: “Luxembourg”
},
{
“phoneCode”: “371”,
“code”: “LV”,
“name”: “Latvia”
},
{
“phoneCode”: “218”,
“code”: “LY”,
“name”: “Libya”
},
{
“phoneCode”: “212”,
“code”: “MA”,
“name”: “Morocco”
},
{
“phoneCode”: “377”,
“code”: “MC”,
“name”: “Monaco”
},
{
“phoneCode”: “373”,
“code”: “MD”,
“name”: “Moldova”
},
{
“phoneCode”: “382”,
“code”: “ME”,
“name”: “Montenegro”
},
{
“phoneCode”: “261”,
“code”: “MG”,
“name”: “Madagascar”
},
{
“phoneCode”: “389”,
“code”: “MK”,
“name”: “Macedonia”
},
{
“phoneCode”: “223”,
“code”: “ML”,
“name”: “Mali”
},
{
“phoneCode”: “95”,
“code”: “MM”,
“name”: “Myanmar”
},
{
“phoneCode”: “976”,
“code”: “MN”,
“name”: “Mongolia”
},
{
“phoneCode”: “853”,
“code”: “MO”,
“name”: “Macau”
},
{
“phoneCode”: “596”,
“code”: “MQ”,
“name”: “Martinique”
},
{
“phoneCode”: “222”,
“code”: “MR”,
“name”: “Mauritania”
},
{
“phoneCode”: “1”,
“code”: “MS”,
“name”: “Montserrat”
},
{
“phoneCode”: “356”,
“code”: “MT”,
“name”: “Malta”
},
{
“phoneCode”: “230”,
“code”: “MU”,
“name”: “Mauritius”
},
{
“phoneCode”: “960”,
“code”: “MV”,
“name”: “Maldives”
},
{
“phoneCode”: “265”,
“code”: “MW”,
“name”: “Malawi”
},
{
“phoneCode”: “52”,
“code”: “MX”,
“name”: “Mexico”
},
{
“phoneCode”: “60”,
“code”: “MY”,
“name”: “Malaysia”
},
{
“phoneCode”: “258”,
“code”: “MZ”,
“name”: “Mozambique”
},
{
“phoneCode”: “264”,
“code”: “NA”,
“name”: “Namibia”
},
{
“phoneCode”: “687”,
“code”: “NC”,
“name”: “New Caledonia”
},
{
“phoneCode”: “227”,
“code”: “NE”,
“name”: “Niger”
},
{
“phoneCode”: “672”,
“code”: “NF”,
“name”: “Norfolk Island”
},
{
“phoneCode”: “234”,
“code”: “NG”,
“name”: “Nigeria”
},
{
“phoneCode”: “505”,
“code”: “NI”,
“name”: “Nicaragua”
},
{
“phoneCode”: “31”,
“code”: “NL”,
“name”: “Netherlands”
},
{
“phoneCode”: “47”,
“code”: “NO”,
“name”: “Norway”
},
{
“phoneCode”: “977”,
“code”: “NP”,
“name”: “Nepal”
},
{
“phoneCode”: “674”,
“code”: “NR”,
“name”: “Nauru”
},
{
“phoneCode”: “683”,
“code”: “NU”,
“name”: “Niue”
},
{
“phoneCode”: “64”,
“code”: “NZ”,
“name”: “New Zealand”
},
{
“phoneCode”: “968”,
“code”: “OM”,
“name”: “Oman”
},
{
“phoneCode”: “507”,
“code”: “PA”,
“name”: “Panama”
},
{
“phoneCode”: “51”,
“code”: “PE”,
“name”: “Peru”
},
{
“phoneCode”: “689”,
“code”: “PF”,
“name”: “French Polynesia”
},
{
“phoneCode”: “675”,
“code”: “PG”,
“name”: “Papua New Guinea”
},
{
“phoneCode”: “63”,
“code”: “PH”,
“name”: “Philippines”
},
{
“phoneCode”: “92”,
“code”: “PK”,
“name”: “Pakistan”
},
{
“phoneCode”: “48”,
“code”: “PL”,
“name”: “Poland”
},
{
“phoneCode”: “508”,
“code”: “PM”,
“name”: “St. Pierre And Miquelon”
},
{
“phoneCode”: “351”,
“code”: “PT”,
“name”: “Portugal”
},
{
“phoneCode”: “595”,
“code”: “PY”,
“name”: “Paraguay”
},
{
“phoneCode”: “974”,
“code”: “QA”,
“name”: “Qatar”
},
{
“phoneCode”: “262”,
“code”: “RE”,
“name”: “Reunion Islands”
},
{
“phoneCode”: “40”,
“code”: “RO”,
“name”: “Romania”
},
{
“phoneCode”: “381”,
“code”: “RS”,
“name”: “Serbia”
},
{
“phoneCode”: “7”,
“code”: “RU”,
“name”: “Russia”
},
{
“phoneCode”: “250”,
“code”: “RW”,
“name”: “Rwanda”
},
{
“phoneCode”: “966”,
“code”: “SA”,
“name”: “Saudi Arabia”
},
{
“phoneCode”: “677”,
“code”: “SB”,
“name”: “Soloman Islands”
},
{
“phoneCode”: “248”,
“code”: “SC”,
“name”: “Seychelles”
},
{
“phoneCode”: “46”,
“code”: “SE”,
“name”: “Sweden”
},
{
“phoneCode”: “65”,
“code”: “SG”,
“name”: “Singapore”
},
{
“phoneCode”: “290”,
“code”: “SH”,
“name”: “St. Helena”
},
{
“phoneCode”: “386”,
“code”: “SI”,
“name”: “Slovenia”
},
{
“phoneCode”: “421”,
“code”: “SK”,
“name”: “Slovakia”
},
{
“phoneCode”: “232”,
“code”: “SL”,
“name”: “Sierra Leone”
},
{
“phoneCode”: “378”,
“code”: “SM”,
“name”: “San Marino”
},
{
“phoneCode”: “221”,
“code”: “SN”,
“name”: “Senegal”
},
{
“phoneCode”: “252”,
“code”: “SO”,
“name”: “Somalia”
},
{
“phoneCode”: “597”,
“code”: “SR”,
“name”: “Suriname”
},
{
“phoneCode”: “239”,
“code”: “ST”,
“name”: “Sao Tome And Principe”
},
{
“phoneCode”: “503”,
“code”: “SV”,
“name”: “El Salvador”
},
{
“phoneCode”: “268”,
“code”: “SZ”,
“name”: “Swaziland”
},
{
“phoneCode”: “1”,
“code”: “TC”,
“name”: “Turks And Caicos Islands”
},
{
“phoneCode”: “235”,
“code”: “TD”,
“name”: “Chad”
},
{
“phoneCode”: “228”,
“code”: “TG”,
“name”: “Togo”
},
{
“phoneCode”: “66”,
“code”: “TH”,
“name”: “Thailand”
},
{
“phoneCode”: “992”,
“code”: “TJ”,
“name”: “Tajikistan”
},
{
“phoneCode”: “690”,
“code”: “TK”,
“name”: “Tokelau”
},
{
“phoneCode”: “670”,
“code”: “TL”,
“name”: “Timor-leste”
},
{
“phoneCode”: “993”,
“code”: “TM”,
“name”: “Turkmenistan”
},
{
“phoneCode”: “216”,
“code”: “TN”,
“name”: “Tunisia”
},
{
“phoneCode”: “676”,
“code”: “TO”,
“name”: “Tonga”
},
{
“phoneCode”: “90”,
“code”: “TR”,
“name”: “Turkey”
},
{
“phoneCode”: “1”,
“code”: “TT”,
“name”: “Trinidad And Tobago”
},
{
“phoneCode”: “688”,
“code”: “TV”,
“name”: “Tuvalu”
},
{
“phoneCode”: “886”,
“code”: “TW”,
“name”: “Taiwan”
},
{
“phoneCode”: “255”,
“code”: “TZ”,
“name”: “Tanzania”
},
{
“phoneCode”: “380”,
“code”: “UA”,
“name”: “Ukraine”
},
{
“phoneCode”: “256”,
“code”: “UG”,
“name”: “Uganda”
},
{
“phoneCode”: “1”,
“code”: “US”,
“name”: “United States”
},
{
“phoneCode”: “598”,
“code”: “UY”,
“name”: “Uruguay”
},
{
“phoneCode”: “998”,
“code”: “UZ”,
“name”: “Uzbekistan”
},
{
“phoneCode”: “39”,
“code”: “VA”,
“name”: “Holy See (vatican City)”
},
{
“phoneCode”: “1”,
“code”: “VC”,
“name”: “Saint Vincent And The Grenadines”
},
{
“phoneCode”: “58”,
“code”: “VE”,
“name”: “Venezuela”
},
{
“phoneCode”: “1”,
“code”: “VG”,
“name”: “British Virgin Islands”
},
{
“phoneCode”: “84”,
“code”: “VN”,
“name”: “Vietnam”
},
{
“phoneCode”: “678”,
“code”: “VU”,
“name”: “Vanuatu”
},
{
“phoneCode”: “681”,
“code”: “WF”,
“name”: “Wallis And Futuna”
},
{
“phoneCode”: “685”,
“code”: “WS”,
“name”: “Samoa”
},
{
“phoneCode”: “967”,
“code”: “YE”,
“name”: “Yemen”
},
{
“phoneCode”: “262”,
“code”: “YT”,
“name”: “Mayotte”
},
{
“phoneCode”: “27”,
“code”: “ZA”,
“name”: “South Africa”
},
{
“phoneCode”: “260”,
“code”: “ZM”,
“name”: “Zambia”
},
{
“phoneCode”: “263”,
“code”: “ZW”,
“name”: “Zimbabwe”
}
]
]
}
],
“errors”: [
{
“code”: “11111”,
“message”: “Invalid Client ID”
}
],
“status”: [
“SUCCESS”
]
}

What do you need to verify? That the object contains certain properties, that they are strings, that the array is a certain length, that a the code matches a certain name, etc

You might need to narrow down the focus of what you’re trying to actually achieve and go from there.

1 Like

First, Thank you for your response Danny -

I need to verify the in the response body all keys have values properly returned. means
{
“code”: “AA”,
“name”: “Armed Forces Americas (not Ca)”
},

for the above snippet for code key should have AA value

not looking to assert the entire response body , but for a portion of it.

What does that give you in the console?

console.log(pm.response.json().options[0].list[0][0].code)

The array inside an array is a bit strange so the syntax is going to look strange. I still have run this yet so it could be undefined. :thinking:

A test could look something like:

let jsonData = pm.response.json()
pm.test("Code equals AA", () => {
    pm.expect(jsonData.options[0].list[0][0].code).to.eql("AA")
})
2 Likes

@LokeshReddy219:

Hi Lokesh, thanks for sharing the response content. As @dannydainton mentioned above you can reach-out to the element and write your tests based on it.

Say for looping, I tried the below sample Tests:

let jsonData = pm.response.json();

for (var i = 0;i<jsonData.options[0].list[0][i].code.length;i++) {

  console.log(jsonData.options.length);

//console.log("Index Value is " + i);

pm.test("Code value check", () => {

    pm.expect(jsonData.options[0].list[0][i].code).to.be.oneOf(["AE","AA","AK"]);

});

}
1 Like