Question for Kin:
I want to validate the values of a particular field in a list which is repeated all over.
Example:
{
"deleates": [
{
"accepted": false,
"applode": "T-APP-M01",
"bot": {
"code": "901",
"key_types": [
{
"code": "uyt",
"value": "1"
}
]
},
"refusal": {
"code": "1306",
"reason": "LANDEDUND"
},
"retention_period_months": "1",
"retention_start_date": "2020-03-10"
},
{
"accepted": false,
"application_code": "T-APP-M01",
"bot": {
"code": "901",
"key_types": [
{
"code": "MA_ID",
"value": "1"
}
]
},
"refusal": {
"code": "502",
"reason": "LANDENVALID"
},
"retention_period_months": "3",
"retention_start_date": "2020-03-10"
}
],
"transaction_id": 462
}
Above one is my response Body and i want to validate the value code which is present in the object “refusal”
deleates is a list and refusal object is repeated twice with 2 different values
Below is the code written by me:
pm.test("Verifying refusal code", function () {
var jsonData = pm.response.json();
console.log(jsonData.deleates[0].accepted);
for (var i = 0; i < jsonData.deleates.length; i++) {
// if(jsonData.deleates[i].accepted == false){
console.log(jsonData.deleates[i].refusal.code);
pm.expect(jsonData.deleates[i].refusal.code).to.eql("1506");
// }
}
});
Below is my test Results:
Verifying refusal code | AssertionError: expected ‘502’ to deeply equal ‘1306’
How to validate the other value in a List of objects. Kindly help