How to validate multiple different data from postman response

Hi, Can some one help on my issue.
I have multiple responses (Around 70) in single request. How to validate this when we have multiple responses. Below i have attached the Image. in that I have responses for stateProvinces.

1 Like

Hi @bharath4172

You are working inside an array so you would need to specify the index you are asserting.

const response = pm.response.json();

pm.test("Check stateDesc values", function () {
    pm.expect(response .stateDesc[0].countryName).to.eql("Michigan");
    pm.expect(response .stateDesc[1].countryName).to.eql("Idaho");
    pm.expect(response .stateDesc[2].countryName).to.eql("Colorado");
    pm.expect(response .stateDesc[3].countryName).to.eql("Utah");
});
1 Like