elect
06/13/2024, 12:01 PM@JvmInline
@kotlinx.serialization.Serializable(with = ResponseSerializer::class)
public value class Response<out T>
@PublishedApi
internal constructor(@PublishedApi
@Polymorphic
internal val value: Any?) : Serializable {
with
<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 status200 OK
Response headerContentType: null
Request headerAccept: 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'
elect
06/13/2024, 12:02 PMArchicad26.client = HttpClient(MockEngine) {
install(ContentNegotiation) {
json(Json {
prettyPrint = true
isLenient = true
})
}
engine {
addHandler {
respondOk(response)
}
}
}
elect
06/13/2024, 12:38 PMCheck that thethe request hasheader in your request specifies the desired content type and that theAccept
header in the server's response matches the expected type on the client side.Content-Type
contentType(ContentType.Application.Json)
. but how can I specify that on the response?elect
06/13/2024, 12:50 PMrespond(response, headers = headersOf(HttpHeaders.ContentType, "application/json"))