manlan
10/19/2020, 11:27 AMimplementation("io.ktor:ktor-server-serialization:1.4.1")
I'm still confused about setting up kotlinx #serialization with ktor 😩Razvan
10/19/2020, 11:33 AMmanlan
10/19/2020, 11:35 AMRazvan
10/19/2020, 11:35 AMplugins {
kotlin("plugin.serialization") version "1.4.10"
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
}
manlan
10/19/2020, 11:37 AMimplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
install(ContentNegotiation) {
Json
}
val input = call.receive<FindReadersInput>()
I receive 415 in Postman when I call this endpoint
@Serializable
data class FindReadersInput (
val location: Location,
val radius : Double
)
@Serializable
data class Location(
@SerialName("lat")
val latitude : Double,
@SerialName("lng")
val longitude: Double,
)
Razvan
10/19/2020, 11:39 AMribesg
10/19/2020, 11:45 AMRazvan
10/19/2020, 11:45 AMmanlan
10/19/2020, 11:46 AMrouting {
post("/readers") {
val input = call.receive<FindReadersInput>()
val readers = DBRepo.getReaders(input.radius, input.location)
call.respond(readers)
}
}
This is my endpoint.
When I hit it, I get 415 unsupported media typeribesg
10/19/2020, 11:48 AMmanlan
10/19/2020, 11:49 AMRazvan
10/19/2020, 11:50 AMribesg
10/19/2020, 11:51 AMmanlan
10/19/2020, 11:54 AMribesg
10/19/2020, 11:55 AMRazvan
10/19/2020, 11:58 AMribesg
10/19/2020, 11:58 AMRazvan
10/19/2020, 11:59 AMmanlan
10/19/2020, 11:59 AMinstall(ContentNegotiation) {
Json
}
ribesg
10/19/2020, 12:00 PMmanlan
10/19/2020, 12:00 PMribesg
10/19/2020, 12:00 PMmanlan
10/19/2020, 12:02 PMribesg
10/19/2020, 12:05 PMRazvan
10/19/2020, 12:06 PMribesg
10/19/2020, 12:07 PMmanlan
10/19/2020, 12:14 PMserialization()
doesn't resolve at all with all the correct dependencies?
If your only contribution to my question is to ask me check the documentation, thanks, I did that already, which didn't seem clear enough to me, bringing me here to ask for help.ribesg
10/19/2020, 12:18 PMktor-serialization
feature?ktor-serialization
not ktor-server-serialization
manlan
10/19/2020, 12:26 PMribesg
10/19/2020, 12:43 PMktor-serialization
to ktor-server-serialization
in the future (it’s being discussed). Ktor used to be server only, so naming everything server
didn’t make sense. Now we have ktor-serialization
and ktor-client-serialization
, it’s confusing.manlan
10/19/2020, 12:58 PM