Hi!
I have problems in a call to an Api Rest. The answer takes between 4-7s to answer and when it does and I'm going to pick up the body I get the following error:
org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 217; received: 115
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
at org.apache.http.conn.EofSensorInputStream$read.call(Unknown Source)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.convertStreamToByteArray(RestAssuredResponseOptionsGroovyImpl.groovy:463)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.charsetToString(RestAssuredResponseOptionsGroovyImpl.groovy:515)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl$charsetToString$3.callCurrent(Unknown Source)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.asString(RestAssuredResponseOptionsGroovyImpl.groovy:181)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.asString(RestAssuredResponseOptionsGroovyImpl.groovy:177)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.print(RestAssuredResponseOptionsGroovyImpl.groovy:155)
at io.restassured.internal.RestAssuredResponseOptionsImpl.print(RestAssuredResponseOptionsImpl.java:224)
at bbva.cucumber.steps.CreateAccountStepdefs.lambda$1(CreateAccountStepdefs.java:86)
at ✽.a new account should be created with 201 status code(features/post-account.feature:20)
Call:
given().headers(commonRequestStepdefs.getHeaders())
.body(bodyJson).log().all()
.when().post(accountPostPath)
.then().statusCode(statusCode)
.body(matchesJsonSchemaInClasspath(jsonSchema));
Expected response:
Status code: 201
Body: {"account_id":"AC-0354afa5-5412-4c6f-9d68-a7e82w321327","account_number":"0309874187","routing_number":"062874186"}
If I delete the .body (matchesJsonSchemaInClasspath (jsonSchema)) statement, everything goes correctly, but when I want to pick up the body, I get the error.
I have tried to configure the connection according to the
documentation as well as extend the call timeout (with HttpClientConfig) but nothing has worked.
I've been searching the internet for several days, but I can not find the solution and I do not have any more ideas.
Thank you!