# ktor

Patrick Ramsey

05/01/2021, 12:11 AM
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]

<|>([uri]) {
    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()?
To be clear, using ktor-client 1.5.3
The official high-level docs seem to mention using contentType() when setting up requests, so I’m a little surprised.
Figured out I could set body to a TextContent() with a contentType set on that. Might be handy to have that in the high level docs!