Search code examples
javascriptpostmanweb-api-testing

How to display specific element from array in GET response


I am testing custom API through Postman. I send GET call, and, in response, I receive an array with many elements. I am just wondering: is it possible to restrict response (in Pre-request script for example) to display only one element in Postman, based, for example, on ID comparison? This is example response:

"Data": {
        "P2PPayees": [
            {
                "Payee": {
                    "PayeeId": "1",
                    "FullName": "Wivhifgik",
                },
            },
            {
                "Payee": {
                    "PayeeId": "2",
                    "FullName": "Mupjidif",
                },
            },
        ]}

Solution

  • It depends on the server which sends the object. Read the documentation and have a look, if you can use query parameters to restrict the response. If the server doesn't support to restrict the response, you have to do it by your own programmatically.