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

**URL:** <https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [November 29, 2018, 3:48pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439 "2018-11-29T15:48:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tombusby](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tombusby](https://community.postman.com/u/tombusby)\
**Post date:** [November 29, 2018, 3:48pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/1 "2018-11-29T15:48:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 29, 2018, 6:23pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/2 "2018-11-29T18:23:11Z")

</div>

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. 😁

---

<div class="post-metadata">

**Author:** ![tombusby](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tombusby](https://community.postman.com/u/tombusby)\
**Post date:** [November 29, 2018, 6:53pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/3 "2018-11-29T18:53:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 29, 2018, 7:15pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/4 "2018-11-29T19:15:24Z")

</div>

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 ☹ ) 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.

---

<div class="post-metadata">

**Author:** ![tombusby](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tombusby](https://community.postman.com/u/tombusby)\
**Post date:** [November 29, 2018, 8:32pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/5 "2018-11-29T20:32:01Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 29, 2018, 8:58pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/6 "2018-11-29T20:58:18Z")

</div>

It wouldn’t really need to be that intelligent if the correct Headers were set in the first place 😁 but I understand what you mean.

---

<div class="post-metadata">

**Author:** ![tombusby](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tombusby](https://community.postman.com/u/tombusby)\
**Post date:** [November 29, 2018, 9:00pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/7 "2018-11-29T21:00:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abhinav](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/abhinav/32/8_2.png) [@abhinav](https://community.postman.com/u/abhinav)\
**Post date:** [November 29, 2018, 9:26pm UTC](https://community.postman.com/t/id-like-to-use-a-test-script-to-set-the-response-view-to-pretty-and-json/3439/8 "2018-11-29T21:26:34Z")

</div>

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
