Search code examples
kotlinkotlin-multiplatformktor-client

Ktor Client, how to specify body parameters


I'm trying to send a POST request to the server, this post requires parameters "email" and "password". but I don't know how to specify parameters, I read the documentation but I didn't understand. this is my code:

val request=client.post<String> {
    url(BASE_URL+"login.php")
    body="email=$email,password=$password"
}

Solution

  • fwiw I use something like following here....though I would have thought specifying url like you do should also work. What issue do you see? The body might also be some json for example, or maybe a data class etc if you have serialization setup.

                response = client.post(url) {
                    body = "some params/data etc"
                }