Hi,
I am trying to invoke RestApi from Gatling which return PDF as response. From POSTMAN its working fine and getting response as 200 with PDF but when running through Gatling getting below error as :
ERROR :
`
java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at org.asynchttpclient.netty.util.Utf8ByteBufCharsetDecoder.decodeSingleNioBuffer(Utf8ByteBufCharsetDecoder.java:152)
at org.asynchttpclient.netty.util.Utf8ByteBufCharsetDecoder.decode(Utf8ByteBufCharsetDecoder.java:165)
at org.asynchttpclient.netty.util.Utf8ByteBufCharsetDecoder.decodeUtf8(Utf8ByteBufCharsetDecoder.java:43)
at org.asynchttpclient.netty.util.ByteBufUtils.byteBuf2String(ByteBufUtils.java:30)
at io.gatling.commons.util.Bytes$.byteArrayToString(Bytes.scala:48)
at io.gatling.http.response.ByteArrayResponseBody.string$lzycompute(ResponseBody.scala:97)
at io.gatling.http.response.ByteArrayResponseBody.string(ResponseBody.scala:97)
at scenarios.ITGScenario$$anonfun$1$$anon$1.(ITGScenario.scala:40)
at scenarios.ITGScenario$$anonfun$1.applyOrElse(ITGScenario.scala:39)
at scenarios.ITGScenario$$anonfun$1.applyOrElse(ITGScenario.scala:37)
`
Code :
override val scenarioBuilder = scenario(“Invoices”)
.exec(
http(“Invoices”)
.get("/api/v1/invoices/18774/pdf")
.header(“VendorID”, “vendor1234”)
.header(“Content-Type”, “application/json”)
.header(“Accept”,“application/pdf”)
.transformResponse {
case response if response.isReceived =>
new ResponseWrapper(response)
`
{ override val body = new ByteArrayResponseBody(Base64.getDecoder.decode(response.body.string), StandardCharsets.UTF_8) }
}
.check(status.is(200))
)
`
Implementation using Base64 Encoding.
Tried solution mentioned in other threads in group and online available but no luck