I am new with ktor , Below is the nodejs code to r...
# ktor
z
I am new with ktor , Below is the nodejs code to return response with status code and json string (working fine and response is getting captured at client side)
res.status(200).json({"message":"foo","something":"something"})
I am trying to reproduce the same functionality with ktor and below is what i tried and it is not getting captured at client side, can someone please help me to wright it in ktor (in single line if possible )
Copy code
call.response.status(HttpStatusCode.OK)
val item = ResponseJson("foo"  , "something")
call.respond(item)
c
Fore sure you don't need to set status code
You also need to use Gson or Jackson
z
I am using jackson , is every thing right with below code ?
Copy code
install(ContentNegotiation) {
    jackson {
        configure(SerializationFeature.INDENT_OUTPUT, true)
        registerModule(JavaTimeModule())
    }
}
c
Yes, it looks like
What client do you use?
it is not getting captured at client side
what are the symptoms ?
z
Using Android as client side and getting following error
retrofit2.adapter.rxjava.HttpException: HTTP 406 Not Acceptable
sorry for confusing it by saying “not captured”
x
You may need to add those header to your http client: Content-Type=application/json
👍 1
Accept=application/json
👍 1
z
Thanks , it worked