I'd like to use a "test" script to set the response view to "pretty" and "JSON"

The API Iā€™m using returns the wrong Content-Type, so itā€™d be nice to be able to use the post-request ā€œtestā€ scripts to set the response viewer pane to the right settings.

Currently I have to manually choose ā€œprettyā€ and ā€œJSONā€ each time, itā€™s fairly annoying.

Personally, Iā€™d be fixing the wrong Content-Type header being returned?

Then you wouldnā€™t have to change anything, on any tool you choose to view the response data.

You canā€™t be the only person impacted by that problem. :grin:

Unfortunately, not going to happen. Itā€™s a deprecated API and will not have its return type changed from ā€œtext/plainā€ but I need to work with it a little longer for various reasons. No more development of any kind on that API will be merged.

Believe it or not, the wrong Content-Type was actually intentional: it stops IE8 from showing a download dialogue for ā€œapplication/jsonā€ :slight_smile:

Now we no longer support IE8ā€¦ but the broken Content-Type remains.

That sucks.

I canā€™t see this being a needed feature within Postman, seems like itā€™s just papering over a problem (albeit something that will never be fixed :frowning: ) rather than solving one.

If the text response is in a JSON ā€˜formatā€™ you could do a JSON.stringify(pm.response.text(), null, 2) and log it to the console.

Sure, thatā€™s definitely an option.

I feel that being able to control some UI elements programmatically could be kind of useful though. This API canā€™t be the only one misreporting its Content-Type. But I donā€™t have really, really strong feelings about it.

Perhaps you could like set ā€œprettyā€ and ā€œJSONā€ for a saved request and just have it always try to use that setting no matter the content-type, rather than having to reset after each call. Or even if it could be a bit more intelligent about ā€œthis looks like itā€™s JSONā€.

It wouldnā€™t really need to be that intelligent if the correct Headers were set in the first place :grin: but I understand what you mean.

Completely agree, but the world is a bit more imperfect than either of us would like it to be I suspect :stuck_out_tongue:

1 Like

Hmm. We donā€™t have a scriptable way to change this but you can force the viewer to try to render JSON by going to the Settings screen and change Language Detection from Auto to JSON

2 Likes