Hello.
I am struggling with nested arrays as response.
Here an example of a response I get:
[
{
"id": "ididididid",
"firstName": "user1",
"lastName": "user1",
"email": "[email protected]",
"replyToAddress": "[email protected]",
"phoneNumber": "1234567890",
"internalUser": false,
"status": "Active",
"userStatus": {
"id": "user_status_id",
"name": "Active",
"enabled": true
},
"groups": [
{
"branch": {
"id": "branch_1_id"
},
"role": {
"id": "role_1_id"
}
}
],
"company": {
"id": "company_1_id",
"roles": [
{
"id": "company_role_1_id"
}
]
}
}
]
What I have tried so far is:
pm.test("Company is example_company_name", () => {
_.each(responseBody.company, (item) => {
pm.expect(item.company.id).to.equal("company_1_id")
})
});
But it does not seem to work correctly.
Response body contains hundreds of elements like that.
What I am trying to do is:
- Want to compare all returned company_id’s are the same and equal to a specific value (let’s say company_1_id).
Please, also advice on a proper source to get familiar with this structure and syntax on how to find nested elements.
Thanks all!