Hi! I'm getting an issue with the ktor client, whe...
# ktor
s
Hi! I'm getting an issue with the ktor client, when I try to make a post request, throws a rare error:
Copy code
override suspend fun addLocation(location: Location): Unit = <http://client.post|client.post> {
        path(LOCATION)
        body = location
    }
It throws
Copy code
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
Copy code
override suspend fun getLocation(parent: Int): Location =
            client.get<Location> { path("$LOCATION/$parent") }
works perfect, the model is quite simple:
Copy code
@Serializable
data class Location(
        val id: Int,
        val parentId: Int,
        val name: String
)
Any suggestions?
e
Hi @Sergio Casero. Could you provide client configuration? The solution depends on what serialization feature do you use.
s
I use JsonFeature with kotlin serialization
I'm out of home, will share complete client in a hour more or less
In a mp project
@e5l
Copy code
private val client = HttpClient {
        install(JsonFeature) {
            serializer = KotlinxSerializer()
        }
    }
right now works wtf
e
Did you test all platforms? It looks like the native should work only with update?