Sergio Casero
11/05/2018, 10:14 AMoverride suspend fun addLocation(location: Location): Unit = <http://client.post|client.post> {
path(LOCATION)
body = location
}
It throws
java.lang.ClassCastException: com.sergiocasero.model.Location cannot be cast to io.ktor.client.call.HttpClientCall
My first impression was a problem with the serializer, but
override suspend fun getLocation(parent: Int): Location =
client.get<Location> { path("$LOCATION/$parent") }
works perfect, the model is quite simple:
@Serializable
data class Location(
val id: Int,
val parentId: Int,
val name: String
)
Any suggestions?e5l
11/05/2018, 10:39 AMSergio Casero
11/05/2018, 11:18 AMSergio Casero
11/05/2018, 11:19 AMSergio Casero
11/05/2018, 11:20 AMSergio Casero
11/05/2018, 3:44 PMprivate val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
Sergio Casero
11/05/2018, 4:52 PMe5l
11/06/2018, 6:29 AM