jsonpostmanvisualize

POSTMAN - Visalize custom made JSON file


I am using postman and would like to visualize the response using the visualizer plugin. The problem is that I am running a GET request on an URL and afterwards in "tests", I am running x number of more requests based on the information received in the initial request. Afterwards, I am taking all of the responses and merging them together so that I now have an extended version of JSON request which has more information. I can log it into console and view all of the information.

The customer would like to visualize this information in Postman using the visualizer plugin but it seems that it does not work - anybody know why? Is is because the plugin is made to work based on only the "main" response received after I click the "Send" button? Is there a way to do it?

Thank you and let me know if you need more information.


Solution

  • The plugin is made to work on whatever you send to. You can even set a new Json on your Tests scripts and render it using pm.visualizer.set(template, data). For example:

    var data = {
        "data" : [
            {
                "name" : "Postmany"
            }
            ]
    };
    var template = `
        <table>
            <tr>
                <th>Name</th>
            </tr>
    
            {{#each response.data}}
                <tr>
                    <td>{{name}}</td>
                </tr>
            {{/each}}
        </table>
    `;
    pm.visualizer.set(template, {
        // Pass the responses you need in a single JSON as data
        response: data
    });
    

    Response:

    Name
    ------------
    Postmany
    

    You can try this code on its own.

    Short answer: Yes you are doing it right, merging your requests on a single JSON, just make sure you are sending it as second parameter and accessing to it correctly on the template.