How to filter response based on specific custom field?

Hey @Venkat.batchu81

It doesn’t look like that endpoint offers the ability to filter down the response, some endpoints would offer that capability via URL params. It looks like they have this for some items like page but not much else.

Depending on your use case you can still do this in a couple of ways with Postman. In the Tests tab, you can loop through the objects in the data array and log the one that contains the email address to the console

_.each(pm.response.json().data, (item) => {
    if(item.email === 'lindsay.ferguson@reqres.in') {
        console.log(item)
    }
})

I’ve also created a template, which can be imported directly into your Postman app, that uses the jsonpath syntax in the Visualizer to filter down the response data.

This would be something that you could use to filter down to an object containing a specific email address:

$..data[?(@.email=='lindsay.ferguson@reqres.in')]

4 Likes