Hi guys, i use kx.ser and i'm stuck with my post ...
# server
d
Hi guys, i use kx.ser and i'm stuck with my post request, the terminal say to me :
Copy code
2021-05-24 17:50:38.841 [eventLoopGroupProxy-4-1] ERROR ktor.application - Unhandled: POST - /Music/Add
io.ktor.features.CannotTransformContentToTypeException: Cannot transform this request's content to Musics
What i have do wrong in my code ? 🥲 (I have do many research and soluce but he doesn't work)
Copy code
post("/Add") {
        val post = call.receive<Musics>()
        aMusicDAO.addMusic(post)
        call.respondText("OK OK",ContentType.Text.Plain)
}

@Serializable
data class Musics(
    val tag:Int? =null,
    @JsonInclude(value=JsonInclude.Include.NON_NULL)
    val title:String?="",
    val artist:String?="",
    val duration: String?="",
    val tagU:Int? =null
)

 override fun addMusic(music: Musics){
        transaction {
                Music.insert{
                    it[title]= music.title ?:""
                    it[artist]=music.artist?:""
                    it[duration]=music.duration?:""
                    it[tagU]=music.tagU?:0
                }
            }
    }
a
Looks like the call.receive line is failing - the request body cant be converted to a music object
Also you shouldn't have /add as your path - that is bad design - post /music is adding/creating
c
It may be you don't Install ContentNegotiation In your App