Open rndev-io opened 4 years ago
any progress? In my project, xml format data is needed. I am figuring how to do...
You can make xml requests already. Use the JsonFeature and provide a serializer with the jackson xml mapper and the "application/xml" content-type:
val client = HttpClient(MockEngine) {
install(JsonFeature) {
serializer = JacksonSerializer(jackson = XmlMapper().registerModule(KotlinModule()))
accept(ContentType.Application.Xml)
}
}
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Just adding something because I spent some time before finding out the problem : Do check in the headers which kind of content you're receiving from your server.
In my case, I was receiving Content-Type: text/xml
and I had to adapt to accept(ContentType.Text.Xml)
, as application wouldn't grab my transformer.
Otherwise, can confirm that XML serialization works like a charm.
Subsystem Client
Is your feature request related to a problem? Please describe. I want to make http requests to XML API.
Describe the solution you'd like Create
ktor-client-xml
like ktor-client-json to (de-) serialize request/response.Motivation to include to ktor XML very popular format for data transferring.