https://kotlinlang.org logo
#ktor
Title
# ktor
m

MBegemot

02/28/2023, 5:46 PM
After updating to 2.2.4 I'm having kotlinx.serialization.SerializationException: Serializer for class 'Any' is not found. Whenever the parameter send to a post is Integer
a

Aleksei Tirman [JB]

03/01/2023, 4:56 PM
Can you share a code snippet to reproduce your issue?
m

MBegemot

03/02/2023, 11:41 AM
Copy code
inline fun<reified T> z(path:String, abody: T?=null):HttpRequestBuilder {
     val sz=HttpRequestBuilder()
     sz.url("<http://knews1939.ey.r.appspot.com/$path>")
     //sz.url("<http://0.0.0.0:8080/$path>")
    //sz.timeout { 1000 }
    //sz.header("Connection", "close")
    //sz.timeout { requestTimeoutMillis=50000
    //             connectTimeoutMillis=5000
    //}
    //sz.header("Accept-Encoding","gzip")
    sz.contentType(ContentType.Application.Json)
    if (abody != null) sz.setBody(abody)
    return sz
 }
    @OptIn(ExperimentalTime::class)
    suspend inline fun <reified T> serverPost33(sNameService: String, params: Any? = null): KResult<T> {
        val tl = measureTimedValue {
            //val u=z(sNameService, params)
            //logger.warn { "PASSSEDDD" }
            //runCatching { <http://client.post|client.post>(u).body<T>() }
            runCatching { <http://client.post|client.post>(z(sNameService, params)).body<T>() }
        }
        val kr=KResult(tl.value, srv_time, tl.duration.inWholeMilliseconds, srv_error,"serverPost33('$sNameService','$params')")
        //if(kr.res.isFailure) logger.error { kr.logInfo() }
        //else logger.debug {  kr.logInfo() }
        client.close()
        return kr
    }
}
the exception rises at client side just when calling post, before the update I haven't got any problem whatever the type was, I think it might be related with kotlin versions as I'm into 1.7.20 (waiting for the release of new BOM for compose)
5 Views