Reputation: 123
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
Upvotes: 0
Views: 1348
Reputation: 525
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);
Upvotes: 1