# How to validate 2 responses in postman with different values

**URL:** <https://community.postman.com/t/how-to-validate-2-responses-in-postman-with-different-values/43423>\
**Category:** Help Hub\
**Created:** [February 1, 2023, 12:16am UTC](https://community.postman.com/t/how-to-validate-2-responses-in-postman-with-different-values/43423 "2023-02-01T00:16:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![francisacobahena](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@francisacobahena](https://community.postman.com/u/francisacobahena)\
**Post date:** [February 1, 2023, 12:16am UTC](https://community.postman.com/t/how-to-validate-2-responses-in-postman-with-different-values/43423/1 "2023-02-01T00:16:35Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/9/b94706a8912cdf098dd07ddd8c6ed75b5b5c9b0e.jpeg)

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

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/2/12d21ca251d6811046c64f0ec2bb72ea4ee7ae71.jpeg)

since it only validates the first

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 1, 2023, 10:57am UTC](https://community.postman.com/t/how-to-validate-2-responses-in-postman-with-different-values/43423/2 "2023-02-01T10:57:21Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![francisacobahena](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@francisacobahena](https://community.postman.com/u/francisacobahena)\
**Post date:** [February 1, 2023, 2:37pm UTC](https://community.postman.com/t/how-to-validate-2-responses-in-postman-with-different-values/43423/3 "2023-02-01T14:37:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 1, 2023, 3:02pm UTC](https://community.postman.com/t/how-to-validate-2-responses-in-postman-with-different-values/43423/4 "2023-02-01T15:02:36Z")

</div>

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.

```auto
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.
