jgritman/httpbuilder

ResponseParseException - HttpBuilder - RestCLient

chethansjce opened this issue · 1 comments

I see the below exception when I submit my request:
groovyx.net.http.ResponseParseException: OK
Request:
def response = new RestClient().post([ "http://endpoint/path",
contentType: ContentType.JSON,
body:
{"s":a, "b":"af"}
])
Groovy version: 2.3.10
HttpBuilder version : 0.7.1
I know that the server responds 200 :OK for this request. I tested it using Advanced Rest Client chrome app.
I referred the thread http://www.groovy-lang.org/mailing-lists.html#nabble-td333800 but not helpful. Please let me know how I can resolve this issue.

StackTrace:
groovyx.net.http.ResponseParseException: Internal Server Error
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:495)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.RESTClient.delete(RESTClient.java:219)
at com.scrippsnetworks.trs.api.test.AbstractTrsSpecification.cleanupSpec(AbstractTrsSpecification.groovy:33)
Caused by: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'c' with an int value of 99
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
could not execute statement; SQL [n/a]; constraint [trs_custom_transcode_fk1]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement����������������������������������������������������������������������������
^
at groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:216)
at groovy.json.internal.JsonParserCharArray.decodeValue(JsonParserCharArray.java:166)
at groovy.json.internal.JsonParserCharArray.decodeFromChars(JsonParserCharArray.java:45)
at groovy.json.internal.JsonParserCharArray.parse(JsonParserCharArray.java:409)
at groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:121)
at groovy.json.JsonSlurper.parse(JsonSlurper.java:224)
at groovyx.net.http.ParserRegistry.parseJSON(ParserRegistry.java:280)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at groovyx.net.http.HTTPBuilder.parseResponse(HTTPBuilder.java:560)
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:489)
... 5 more

I got something similar on a GET action. For me, it was because the response back was accepting gzip/compressed packets. I turned that off in the headers and it started working.