Postman Tests - JSON.parse(responseBody) show the result in console

With Postman Tests I am trying to archive to set some environment variables. Not ofter I do have the question how the response body or the indicidual json field is named and so on so I added some debug into my tests

//console.log(“The whole response body:…” +responseBody)

//JSON Array füllen mit dem Response Body

var json1 = JSON.parse(responseBody);

//console.log("access_token: " +json1.access_token)

//If you know that access_token is there it’s great

pm.environment.set(“access_token”, json1.access_token);

//no I want to show the the whole json structure with
console.log(“The whole json1 struction after parsing:…” +json1)
but the result in console is: The whole json1 struction after parsing:…[object Object]

Hey @juergenschubert,

Welcome to the Community! :star:

Your question was a little difficult to understand but if you’re just trying to log the parsed response body to the console - You can use this in the Tests tab:


This will parse the response and log it in the Console tab and not display this as [object Object].

With each request made, you should also see the full response/response details. These are held within different sections and displayed when you click on the request.

More information on the pm.response.json() command can be found on our learning center:

1 Like

To expand on what @dannydainton said,

console.log will display an object or a string at one time, not both. By adding “The whole json1 structure after parsing:” to your log statement, you are telling it you want to display it as a string. Your options to avoid this are:

Option 1

console.log('The whole json1 structure after parsing:...');

Option 2

console.log('The whole json1 structure after parsing:...', json1);

Option 3

console.log('The whole json1 structure after parsing:...' + JSON.stringify(json1))
1 Like