ktor-client question --- I’m trying to make an HTTP POST request with an xml body and no magic serialization, and to set the ContentType header. I assumed I could do, e.g.
Copy code
val xmlBody: String = [prepare body]
<http://client.post|client.post>([uri]) {
contentType(ContentType.Text.Xml)
body = xmlBody
}
However, I’m getting,
Copy code
io.ktor.http.UnsafeHeaderException: Header(s) [Content-Type] are controlled by the engine and cannot be set explicitly
What’s the correct way to specify the Content-Type header, if not by explicitly calling contentType()?
Patrick Ramsey
05/01/2021, 12:13 AM
To be clear, using ktor-client 1.5.3
Patrick Ramsey
05/01/2021, 12:14 AM
The official high-level docs seem to mention using contentType() when setting up requests, so I’m a little surprised.