Am trying to make an http post request but it is getting failed for reasons am not able to understand.
object KtorClient {
val client = HttpClient() {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
}
suspend fun createOwner(url : String = "http://localhost:112/company/owner/register", ownerMapper: OwnerMapper) {
println(ownerMapper)
client.post<Unit>(url){
body = ownerMapper
}
}
BlockquoteIllegalStateException {message_8yp7un$_0: "Fail to send body. Content has type: class OwnerMapper, but OutgoingContent expected.", cause_th0jdv$_0: null, stack: "captureStack↵Exception↵RuntimeException↵IllegalSta…↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵promiseReactionJob@[native code]", name: "IllegalStateException"}
After adding Serialization plugin, am getting this error:
"Can't locate argument-less serializer for class OwnerMapper. For generic classes, such as lists, please provide serializer explicitly."
I have followed the official example but not able to make it run. Am using Kotlin/Js and above error is coming from browser.