Hey! Running into a silly problem. I want to set t...
# ktor
g
Hey! Running into a silly problem. I want to set the Content-Type to application/json but I don’t want to use the serialization of jackson or gson. When I set the content-type in the request itself I get a UnsafeHeaderException and it states that it should be set from the engine
The idea is to set the content-type along the response
For example:
call.respondText("p { background: red; }", contentType = ContentType.Text.CSS, status = HttpStatusCode.OK)
g
this is in an httpClient, so we do a client.post like this val response = client.post<HttpResponse>(updateUrl) { body = payload contentType(ContentType.Application.Json) }
d
oh I see
g
so it’s not server side on the response-part
d
https://ktor.io/clients/http-client/calls/requests.html#specifying-a-body-for-requests
Copy code
body = TextContent("HELLO WORLD!", ContentType.Text.Plain)
?
the content type is still part of the
OutgoingContent
, so when you generate one, you have to specify it there
g
ah I see, this looks like what I am after
👍 1
wkr
worked splendidly. Thanks for the help!