Is it possible to use the ktor HTTP client to pars...
# ktor
c
Is it possible to use the ktor HTTP client to parse x-www-form urlencoded responses to models, similar to how it parses JSON?
m
I am also looking for a way to do this
p
+1 for me, from what I've gathered so far you could use
call.receiveParameters()
to get what is basically a
Map<String, List<String>>
to work with. This doesn't automatically parse into models like the JSON converters. To use the syntax of
call.receive<MyDataModel>()
with
x-www-form-urlencoded
we need to use the
ContentNegotiation
feature and write our own converter to do the mapping:
Copy code
install(ContentNegotiation) {
    register(ContentType.Application.FormUrlEncoded, FormUrlEncodedConverterThatNeedsWriting())
}
I'm knew to Kotlin so I haven't managed to write a converter to handle form data in the same way as something like Ruby on Rails does using
[ ]
as delimiters. I've made this gist from the JacksonConverterTest incase someone is able to help: https://gist.github.com/createdbypete/ac57c6b59133b184799fadbf32b4b93a