Skip to content
Advertisement

Groovy HTTP ResponseParseException not found

I am trying to make simple GET request using groovy HTTP request. I am expecting JSON response in this form:

JavaScript

So far I have done this in my code:

JavaScript

and I am always getting this response:

JavaScript

I have googled and found out that it’s problem related to groovy and this problem was not occurring before version 2.3.0, like this post is saying.

I tried all answers and hints but none of them helped. What can I do to make my JSON parseable?

Advertisement

Answer

You are trying to fetch data from incorrect URL, see here. Should be:

JavaScript

There’s no test_API part. No page found results in 404 and this answer explains the exception you get.

The script below (with changed URL) works – it gives 401 since I don’t send authentication data:

JavaScript

Also, the API is invalid, the requested response format – Accept header – is application/json and the result is returned in HTML – that’s why http-builder fails – it expects different response format. The eliminate the exception change response.failure closure to:

JavaScript

eliminate the reader param – it will prevent http-builder from parsing the response automatically.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement