Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResponseParseException - HttpBuilder - RestCLient #55

Open
chethansjce opened this issue Jan 14, 2016 · 2 comments
Open

ResponseParseException - HttpBuilder - RestCLient #55

chethansjce opened this issue Jan 14, 2016 · 2 comments

Comments

@chethansjce
Copy link

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

@SonjaMarr
Copy link

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.

@hexmind
Copy link

hexmind commented Dec 5, 2024

10 years later...:)
I think there is still a bug. Request's ContentType is used instead of real one from response. As a workaround to omit 'HTTPBuilder.this.parseResponse' you can move to the case 1 where responseClosure.getMaximumNumberOfParameters == 1.

                        switch (responseClosure.getMaximumNumberOfParameters()) {
                            case 1: // <<< workaround
                                closureArgs = new Object[]{resp};
                                break;
                            case 2:
                                HttpEntity entityx = resp.getEntity();

                                try {
                                    if (entityx != null && entityx.getContentLength() != 0L) {
                                        closureArgs = new Object[]{resp, HTTPBuilder.this.parseResponse(resp, contentType)};  // <<< invalid contentType
                                        break;
                                    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants