• Home
  • Jobs
  • Courses
  • Teachers
  • For business
  • Blog
  • ES/EN

0

17
Views
Ktor JSON Parsing on Post Request is not working

Every time I send a post request from the postman and the server gives this error, even I checked if I'm receiving Content-Type = Application/ JSON. But still giving this error.

Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;

Here are my files

Application File:

fun main() {
    embeddedServer(Netty, port = 8080, host = "192.168.0.109") {
        install(ContentNegotiation){
            json()
        }
        configureRouting()
    }.start(wait = true)
}

Request:

post("/login") {

    val userInfo = call.receive<UserInfo>()
    println(userInfo)

    call.respondText("Everything is working fine")
}

Model Class:

@Serializable
data class UserInfo(
    val email: String,
    val password: String
)
21 days ago ·

Santiago Trujillo

2 answers
Answer question

0

So I Solved This Issue by Changing Project SDK 1.8 to 11.

enter image description here

21 days ago · Santiago Trujillo Report

0

ktor_version:1.6.7 has fixed this problem.

21 days ago · Santiago Trujillo Report
Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.