qwert_ukg
04/17/2023, 9:36 AMinstall(ContentNegotiation) {
json()
}
val client = HttpClient(CIO)
routing {
get("/users") {
val users: List<User> = client.get("$host/api/v4/users?private_token=$token").body()
call.respond(users)
}
}
@Serializable
data class User(
val id: String,
val username: String,
)
this code returns this error io.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class kotlin.collections.List
Goetz Markgraf
04/17/2023, 9:47 AMio.ktor:ktor-serialization-kotlinx-json-jvm
and not org.jetbrains.kotlinx:kotlinx-serialization-json
qwert_ukg
04/17/2023, 10:17 AM...
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation as ContentNegotiationServer
...
install(ContentNegotiationServer) {
json()
}
val client = HttpClient(CIO) {
install(ContentNegotiation) {
json()
}
}
routing {
get("/users") {
val users: List<User> = client.get("$host/api/v4/users?private_token=$token").body()
call.respond(users)
}
}
and its workqwert_ukg
04/17/2023, 10:18 AMGoetz Markgraf
04/17/2023, 10:23 AMio.-ktor.server
the other io.ktor.client
). Maybe you should put the initialization in two different files. Or you live with the alias or a full package name in the install()
-callqwert_ukg
04/17/2023, 10:24 AMqwert_ukg
04/17/2023, 10:28 AM