https://kotlinlang.org logo
#ktor
Title
# ktor
l

Lawik

05/23/2019, 9:34 AM
How can I prevent this ktor-client exception when the response type is nullable and the body is empty?
Copy code
ReceivePipelineException: Fail to run receive pipeline: NoTransformationFoundException: No transformation found: class JsHttpResponse -> class ExerciseProgressDTO
e

e5l

05/23/2019, 9:45 AM
Hi, @Lawik . What version of ktor do you use?
l

Lawik

05/23/2019, 9:47 AM
Copy code
implementation "io.ktor:ktor-client-js:1.1.3" implementation "io.ktor:ktor-client-json-js:1.1.3"
Though, maybe it will be solved if my body contains an empty json object instead? I'll give that a try too.
Nevermind, that gives me a MissingFieldException.
d

Dico

05/23/2019, 1:13 PM
You can configure Jackson not to fail on empty beans
(disableFeature(DeserializationFeature.FAIL_ON_EMPTY_BEANS)
l

Lawik

05/23/2019, 1:45 PM
My problem is on the frontend though, I want ktor to return null when my body is empty and my response type is nullable.
d

Dico

05/23/2019, 1:48 PM
Ktor (as far as I can tell) only supports passing
KClass<T>
, which would mean that this is not possible. It would need some kind of Type Token to support this.
2 Views