Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send Http Form with parameters by ktor-client

I've found nearly everywhere in ktor-client documentation and examples they use empty formData to show how the client works

formParameters: Parameters = Parameters.Empty

So what's the kotlin/ktor way to fill it with parameters?

like image 454
vdshb Avatar asked May 26 '19 07:05

vdshb


1 Answers

Ktor uses this approach to fill the parameters:

client.submitForm<HttpResponse>(
        url = "https://foo.com/login",
        formParameters = Parameters.build {
            append("_username", username)
            append("_password", password)
        })
like image 118
vdshb Avatar answered Sep 21 '22 13:09

vdshb