Has anyone experienced a problem while parsing jso...
# ktor
g
Has anyone experienced a problem while parsing json api response when content type is not “application/json” ?
I’m trying to send a request and parse server’s response using ktor which is quite straightforward. But unfortunately, server uses wrong “content-type”, “text/html” instead of “application/json” which causes “KotlinException, No transformation found” Seems ktor uses “content-type” from response header to choose deserializer. I tried to override response’s header using interceptor but didn’t work either
Copy code
addInterceptor { chain ->
                val request = chain.request()

                val response = chain.proceed(request)

                val header = response.headers.newBuilder()
                    .add("Content-Type", "application/json")
                    .build()

                response.newBuilder()
                    .headers(header)
                    .build()
            }
c
Why don’t you get the response body as string, then deserialize it???
c