I'm trying to deserialize a mocked response to thi...
# serialization
e
I'm trying to deserialize a mocked response to this:
Copy code
@JvmInline
@kotlinx.serialization.Serializable(with = ResponseSerializer::class)
public value class Response<out T>
@PublishedApi
internal constructor(@PublishedApi
                     @Polymorphic
                     internal val value: Any?) : Serializable {
with
Copy code
<http://Archicad26.client.post|Archicad26.client.post>("<http://localhost:19723>") {
    contentType(ContentType.Application.Json)
    setBody(command)
}.body()
but I get
Expected response body of the type 'class Response' but was 'class io.ktor.utils.io.ByteBufferChannel'
In response from
<http://localhost:19723>
Response status
200 OK
Response header
ContentType: null
Request header
Accept: application/json
You can read how to resolve NoTransformationFoundException at FAQ:
https://ktor.io/docs/faq.html#no-transformation-found-exception
io.ktor.client.call.NoTransformationFoundException: Expected response body of the type 'class Response' but was 'class io.ktor.utils.io.ByteBufferChannel'
the mocking:
Copy code
Archicad26.client = HttpClient(MockEngine) {
        install(ContentNegotiation) {
            json(Json {
                prettyPrint = true
                isLenient = true
            })
        }
        engine {
            addHandler {
                respondOk(response)
            }
        }
    }
the first FAQ says
Check that the
Accept
header in your request specifies the desired content type and that the
Content-Type
header in the server's response matches the expected type on the client side.
the request has
contentType(ContentType.Application.Json)
. but how can I specify that on the response?
indeed I just missed to set the contentType on the response
Copy code
respond(response, headers = headersOf(HttpHeaders.ContentType, "application/json"))