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