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.
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”
Now we no longer support IE8… but the broken Content-Type remains.
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 ) 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.
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”.
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