Response type override
Feature Request
I’m currently dealing with a poorly implemented RESTful API that returns a JSON response, but the Content-Type header is always text/html. This means that selecting the Pretty formatting in the response panel will try and make it pretty HTML, not JSON.
It would be SOOOOO incredibly fantastic if I could override the response type so that I can have the nice JSON formatting I get when the API is correctly implemented and returns application/json.
A simple solution may perhaps be in the response panel, you could add JSON next to Pretty and RAW to manually display the response as pretty JSON?
Linux2024.13.0
I could have sworn I added logic to do this automatically, but it might only be for text plain. I’ll get that working
Thanks! You forget how useful collapsible JSON is until you don’t have it! LOL
Also include for type “text/javascript”?
I forgot to put this in the changelog, but I believe it should be fixed now
What version is this released in? I have 2025.1.2 but it is still not working as expected. If that is the correct version, let me know if I need to supply logs or any further information. Thanks!
I used the following request to reproduce Yaak correctly highlighting the data:
```
curl -X POST 'https://yaak.app/x/echo'
--header 'Content-Type: text/html'
--data-raw '{ "foo": "bar" }'
```
The detection algorithm is fairly basic, so perhaps your returned JSON is not being detected? Yaak simply checks if the content starts with
{or[. Does your response start with whitespace or some other character that may be skipping this detection?haha. Nailed it! I didn’t notice, but there is a single white-space character in front of the JSON.
Cool, I’ll make sure to handle that case!
Thanks, Greg. You’re a bloody legend! (that’s a really nice Aussie compliment).
Just fixed the whitespace issue in my dev branch
https://yaak.app/blog/2025.2.0-beta.1
Just tested the BETA and it’s working great now. Thanks!
Awesome, thanks for letting me know!
I would still like a “JSON” option, too, because there’s a weird API I work with that wraps the JSON response in HTML code.
https://yaak.app/blog/2025.2.0
Sorry, but I don’t see any of this in Version 2025.2.0 (20250520.152610).
Ah yes, there’s no explicit selector, just better auto detection. Did this not work for you?
Unfortunately, it did not. Leading spaces are throwing off auto-detection, and there are some cases where the JSON is wrapped in HTML, so I need the ability to explicitly force the output to be interpreted as JSON in order to see the data prettied.
Here’s an example:
I quickly added logic for this in 2025.2.2
For the HTML example, can you paste a text response here so I can see what it looks like? Formatting JSON within HTML will be more difficult.
Here’s a thrown-together example: