Closed LifeIsStrange closed 3 years ago
I have the same problem with GSON
So basically it is imossible to receive the body in a get request in Ktor? Isn't this a fundamental basic feature ?
Could you please remove json feature and just receive text via method HttpResponse.readText
? Probably, server returns invalid result. As I assume, server returns html page (with access denied content), which is not valid json response.
I cant find HttpResponse.readText, for HttpResponse intellij auto import import io.netty.handler.codec.http.HttpResponse but cant find readText method. Isnt that just for the client ? I dont have a Ktor client, I use postman. How can I receive a get request with content type as application/json (I do not precise UTF8 is that wrong ?) as text inside my route ?
@LifeIsStrange , oh, sorry, my fault. I thank you asked about Http Client. I felt json errors with it, this is reason of me here. And I caught real problem with uncompleted data, which is returned by Apache server.
In regards to your question, code is like this (please note - url is not valid):
val responseText = HttpClient().use { client ->
client.get<String>("https://github.com/ktorio/ktor/issues/1445") {
accept(ContentType.Application.Json)
}
}
Of course client should be reused if possible. And please check here about Accept header.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Cannot reproduce with Ktor 1.6.1.
Ktor Version and Engine Used (client or server and name) version, client/server, additional ktor modules included
Describe the bug Jackson cant serialize a json into a model on Get but it works on Post with the exact same code.
Expected behavior Ability to serialize body json in get method.
By sending in postman:
GET http://0.0.0.0:8080/users/auth
in raw jsonI get the following error (unlike with post for the same request)
ps:
I've installed jackson with