Filter in body tab, by Name, by ID

Hello, i want to know how can I filter responses on the body tab,

Let me explain :
I have one GET request, and I have so many information in the body tab, I want to have only
the Name
the ID

Linked, a picture of my body tab

Best regards, thanks a lot.

Hey @MarvynRocher,

Welcome to the community!! :rocket:

There currently isn’t a way to filter the response body in that window but there is an open Feature Request that you can leave a :+1: on.

You do have 2 options that I can think of to just display that data though :slight_smile:

You can add a script to the Tests tab to loop through the data and console.log() the values you want to see in the Postman Console. This isn’t the most elegant solution but it should work for your needs:

let respData = []

_.each(pm.response.json().d.results, (item) => {
    respData.push({
        Id: item.Id,
        Name: item.Name
    })
})

console.log(respData)

55

Or you can use our awesome new Visualizer feature to display the data in the Visualize tab:

Just add this script to the Tests tab and you should see the output in a table (If I have the correct reference in place :slight_smile: ), I’ve added some CSS to the table to make it look slightly better but it’s not really needed.

var template = `
    <style type="text/css">
        .tftable {font-size:14px;color:#333333;width:50%;border-width: 1px;border-color: #729ea5;border-collapse: collapse;}
        .tftable th {font-size:18px;background-color:#acc8cc;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;text-align:left;}
        .tftable tr {background-color:#ffffff;}
        .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;}
        .tftable tr:hover {background-color:#e0ffff;}
    </style>
    
    <table class="tftable" border="1">
        <tr>
            <th>Id</th>
            <th>Name</th>
        </tr>
        
        {{#each response.d.results}}
            <tr>
                <td>{{Id}}</td>
                <td>{{Name}}</td>
            </tr>
        {{/each}}
    
    </table>
`;

pm.visualizer.set(template, {
    response: pm.response.json()
});  

1 Like

Hello, thanks to have answered! But when I pasted the first method, nothing is done. I’ve pasted the first method to the Test Tab and nothing is done.
Linked a picture

Thanks for all

You would see this output in the Postman Console, you can open it via this icon:

The reference (pm.response.json().d.results) to the array is based on seeing a picture of part of your response body so it might be wrong. :confused:

Thanks a lot it’s work !
I have some another questions if you have time!
Let’s me explain
With the same idea, I have for example one Name : Marvyn;
And I want to know the informations linked to this Name, there are some informations :

  • The role
  • The Account
    Which Are linked to a Name.

Same question if we have a Account…

Can you have some explains/Solutions?

Thanks a lot for all !