Eduardo Ruesta
04/22/2024, 7:36 PMpost {
val formParameters = call.receiveParameters()
val firstName = formParameters.getOrFail("firstName")
val lastName = formParameters.getOrFail("lastName")
val email = formParameters.getOrFail("email")
val customer = dao.addNewCustomer(firstName, lastName, email)
call.respond(mapOf("customer" to customer))
}
where customer is the route (/customer)
: Im trying to add a new customer using curl command: curl -H "Content-Type: application/json" -d '{"firstName": "Raul", "lastName": "Garcia", "email": "<mailto:raulGar@mail.com|raulGar@mail.com>"}' <http://127.0.0.1:8080/customer>
and im having the issue
2024-04-22 162936.461 [eventLoopGroupProxy-4-3] DEBUG Application - Unhandled: POST - /customer. Exception class io.ktor.server.plugins.BadRequestException: Failed to convert request body to class io.ktor.http.Parameters
Caused by: io.ktor.serialization.JsonConvertException: Illegal input: Polymorphic serializer was not found for missing class discriminator ('null')
JSON input: {"firstName":"Raul","lastName":"Garcia","email":"raulGar@mail.com"}
Eduardo Ruesta
04/22/2024, 7:37 PMChrimaeon
04/22/2024, 7:45 PM-d
Chrimaeon
04/22/2024, 7:46 PMChrimaeon
04/22/2024, 7:47 PMEduardo Ruesta
04/22/2024, 7:48 PM