0

I have a JSON Collection of Postman requests. I am running it via Newman. Is there a way I can export the XML Response of a particular request(Not all) to a file using newman or postman

Thanks

Archit Goyal
  • 83
  • 1
  • 2
  • 6

1 Answers1

1

As I know, there is no developed XML reporter for newman. The easiest and none-blood way to quickly resolve it this is to add response parsing to certain request or to a collection (if you need for all)

In tests you can add:

let responseJSON = JSON.parse(responseBody)
tests["Status code is 200"] = responseCode.code === 200;
if(responseCode.code !== 200)
{
    console.log(responseJSON); 
    return;
}

OR

try {
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("jwt_token", jsonData.data.token);
} catch (err) {
    console.log(err);
}

OR if you don't need to output it only after an error, then put just:

var body = JSON.parse(responseBody)
console.log(body);
Alexander Tunick
  • 517
  • 1
  • 6
  • 20