How to validate 2 responses in postman with different values

Hi, good evening. I’m trying to validate a response from a service that is returning 2 results

This is the code where I only validate one answer but how can I do it to validate the other result or more results

since it only validates the first

What do you mean by it only validates the first?

You have two tests in your code, one for the status code and it has to pass all of the pm.expect lines in the second test.

I can see that both tests have passed.

Your code appears to be checking both array elements, so should cover both records\results.

Maybe split the tests into two separate tests.

It’s not going to scale very well if you have lots of results, which is where you need to get your data driven test working properly. (Which you had in your previous post).

If it is passed but only because it reads the first result of the array but the second one no longer reads it, I have to comment the code of the first array so that it can read it. I would like to know if it is possible to read both at the same time to automate that part

Sorry, I’m still not quite understanding what you are trying to achieve.

In your screenshot example, you are checking all of the elements in both results.

pm.expect(jsonData[0].profileID).to.eqls(7275);
pm.expect(jsonData[1].profileID).to.eqls(7158);

This is checking the profileID in both results. You are targeting both of the results.
I’ve already mention that it might be better to separate this into individual tests.

If the first element fails, then it will not check any of the other pm.expect lines.
It will abort the test at that point.

If you have more array elements, then you are going to have to keep extending this method.

You could loop through the results, and embed the test in that loop, but not sure how this would work as you need to know the data (expected result) for each assertion.