PM Response within a loop


I have an initial call to an API that gives me a list, that I then loop through and want to export the response from the 2nd call to the console. However, the console only seems to output the response of the initial call.

Help would be greatly appreciated.

Here is the Test Body

var isJson = false;
var TriggerEvent = ‘’;
var i;
var jsonData = ‘’;

var dataResponse = JSON.parse(responseBody);
isJson = true;
console.log(‘responseBody is not JSON’);

postman.setEnvironmentVariable(“arrayLength”, _.size(dataResponse.triggeringEvents) );

for (i = 0; i < environment.arrayLength; i++)  
    TriggerEvent = '';
    postman.setEnvironmentVariable("TriggerEvent" , dataResponse.triggeringEvents[i]);
        url: pm.environment.get("url") + '/api/v1/administrators/marketplaces/' + pm.environment.get("default_marketplace") + '/message_templates?triggeringEvent=' + pm.environment.get("TriggerEvent"), 
        method: 'GET',
        header: 'X-Token:' + pm.environment.get("token"),
        body: {
            mode: 'json'
    console.log(pm.response.json()) //This is giving the response from the the GET not the GET in the pm.sendRequest, how do you get that response outputted. 


You need to use the response available in the callback that you pass to pm.sendRequest

        url: "",
        method: "GET",
        headers: {},
        body: {}
     function (err, res) {
        // This is the response you are looking for

Thanks for this.
What I’ve noticed is that when I run this with Newman, that some strings are getting line breaks to the next line. I have some long HTML strings, but don’t want them cut off. Is there a way to prevent this?

Newman uses the cli reporter by default if no other reporter is specified. The cli reporter prettifies the console log output by using appropriate colors and wrapping the text based on the dimensions of the window the console is running in.

This is what I could figure out by looking at the code in utils and the code that listens to the console log events.

You might be able to tweak that code a bit to take in a configuration to not wrap the log and send a PR to that code. Alternatively you could also create your own custom reporter or use one of the other reporters available.