cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
705
Views
5
Helpful
0
Comments
snovello
Cisco Employee
Cisco Employee

If you use postman with NSO, you will have noticed that when you use the ?dry-run=cli or ?dry-run=native query parameters, the result is hard to read because the 'pretty' 'raw' 'preview' tabs are displaying newline as '\n'.

 

To get around that you can define a visualiser. You do this by adding the code below to the 'Tests' for your request.

Then when you run your request, in the 'visualise' tab you will have a  formatted dry run output

 

 

 

// The visualiser will produce html
// For dryrun=cli use the preformatted text tag to properly print newlines
var clitemplate = `<pre>{{dryrun}}</pre>`;

// For dryrun=native we get a structured object and the template can generate a table
var nativetemplate = `
<table>
        <tr>
            <th>Device</th>
            <th>Changes</th>
        </tr>

        {{#each device}}
            <tr>
                <td valign="top">{{name}}</td>
                <td><pre>{{data}}</pre></td>
            </tr>
        {{/each}}
</table>
`;
// test for a body
if (pm.response.text()) {
    // Set visualizer and choose a template based on cli or native response type
    var j = pm.response.json()['dry-run-result']
    if (j && j.cli) {
        pm.visualizer.set(clitemplate, {
            // Traverse response json to get the dry-run diff
            dryrun: pm.response.json()['dry-run-result'].cli['local-node'].data
        })
    }
    if (j && j.native) {
         pm.visualizer.set(nativetemplate, {
            // Traverse response json to get the list of device objects
            device: pm.response.json()['dry-run-result'].native.device
        })       
    }
}

 

 

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: