Hi, while calling ktor API, if my query is of diff...
# ktor
a
Hi, while calling ktor API, if my query is of different type, I’m getting below exception java.lang.IllegalStateException: Serializing collections of different element types is not yet supported. Selected serializers: [kotlin.String, kotlin.Int]
Copy code
val query = hashMapOf<String,Any>(
    KEY_OTP to otp.toInt(),
    KEY_MOBILE to phone
)
This is what I’ve posted However I achieved the excepted result by sending a model class as
Copy code
@Serializable
data class OTPRequest(
    val mobile : String,
    val otp : Int
)
But I was wondering, It’ll be a extra burden if I’m going to create multiple request classes Any solution will be helpful. thanks
r
You should be able to use
JsonObject
from kotlinx serialization.
a
Yes that worked Thanks