Anybody knows how you can still accept content-typ...
# ktor
g
Anybody knows how you can still accept content-type text/plain after installing content negotiation with jackson? Right now I have
Copy code
install(ContentNegotiation) {
            jackson {

            }
}
but then I get unsupported media type when posting with text/plain. Would like to support both of these formats as default …my google wizardry is starting to drain 😞
t
You may need to define a separate route to handle plain text. I am on mobile and have not been able mess with it.
o
Do you mean treat plain text as json?
t
I think he wants to be able to handle either content type.
o
ContentNegotiation
only kicks in when you receive a custom class from the call, like
call.receive<Person>()
, so if you wish to receive a data type from the call when content-type is set to
text/plain
and treat is a JSON, you need to register JSON converter (see how
jackson
function is implemented) for that content type.
g
That makes sense! Thank you both 😊