https://kotlinlang.org logo
#ktor
Title
# ktor
s

Shan

03/02/2020, 11:00 PM
Hey all. I have my
AndroidEngineConfig
set up in a way that if the method isn't
GET
,
HEAD
or
DELETE
to set the content type to
ContentType.Application.Json
. This is fine for all of my
POST
requests with bodies, but I now need to make a
POST
request without a body (it is only a path with an Empty response), and I am getting:
Copy code
io.ktor.http.UnsafeHeaderException: Header Content-Type is controlled by the engine and cannot be set explicitly
Is there any way I can override the
Content-Type
for this single request, or is there a way I can programmatically set it for each individual request?
I was thinking of making a second engine for content-types that aren't Json but I don't know if that's overkill
r

ribesg

03/03/2020, 10:53 AM
Can’t you just set the content type in the request builder?
e

e5l

03/03/2020, 11:55 AM
Hi @Shan, sorry for the long delay. You can set content type header in
OutgoingContent
body.
s

Shan

03/04/2020, 12:28 AM
ooh, thank you!