Json response body starts with < which breaks my console.log

So, I’m trying to log the response body, however it starts with < and it breaks my collection run.
How do I get around this?

Hi @theToncheff

That seems odd to me, since normal json does not start with a <.

Can you show us a screenshot of the json that is in the response body?


Sorry for late reply, anyway here is the pic - image
This happens when I add to the tests

I don’t know if it matters, the request is GET , the body is roughly 1560 lines of html code?

Hi @theToncheff,

Thanks for the screenshot and clarifying your response!

Given what I see; and hearing you say it’s HTML, you won’t be able to parse it with pm.response.json(), because it isn’t json.

If you are trying to really get data out of that HTML, I would suggest Cheerio.js, though the syntax is a bit more difficult. That should give you the ability to parse HTML in the way you’d like.

If you’re curious, I have a video on Cheerio.js for XML, but it will also work with HTML.

Hope this helps!


If it’s HTML and you just want to view it in the console, you can use console.log(pm.response.text()) instead but that wont really help you parse it.

As well as @odanylewycz’s awesome tutorial, I know that @vdespa has created a few videos around working with XML/HTML responses.