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

rodrigo

04/09/2019, 11:44 AM
Hi guys, whenever I use
HttpRequestBuilder
and try to specify
ContentType(ContentType.Application.Json)
I get
Header Content-Type is controlled by the engine and cannot be set explicitly
. I’ve tried adding
defaultRequest { ContentType }
into the
HttpClient {  }
but I still get the same error. How would I go about setting the content type?
e

e5l

04/09/2019, 12:27 PM
Hi @rodrigo, what version of ktor do you use?
r

rodrigo

04/09/2019, 12:28 PM
@e5l version
1.1.3
e

e5l

04/09/2019, 12:28 PM
You could specify
ContentType
in request
body
using OutgongContent subtype.
Also, you could use
JsonFeature
and it does it for you.
r

rodrigo

04/09/2019, 12:30 PM
cool I will try, thank you!
5 Views