question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

call.respond(Object) cause error

See original GitHub issue

At sample json for example: java.lang.IllegalArgumentException: Response pipeline couldn't transform 'class org.jetbrains.ktor.samples.json.Model' to the FinalContent

//ktor-test-host used

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mohammadrafighcommented, Sep 19, 2017

I have the same problem. @cy6erGn0m Gson is installed, and @orangy application/json is set both for request and response. but the only thing works is that I manually convert to Json like this: call.respond(gson.toJson(myObject))

0reactions
mustii82commented, Oct 11, 2018

Same Issue:

import io.ktor.application.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*

class Person(val vorname: String, val nachname: String)

object PersonManager{
   fun getAllPersons()= Person("Bill","Gates")
}

fun main(args: Array<String>) {

    val server = embeddedServer(Netty, port = 8080) {
        routing {
            get("/hi") {
                call.respond(PersonManager.getAllPersons())
            }
            get("/demo") {
                call.respondText("HELLO WORLD!")
            }
        }
    }
    server.start(wait = true)
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Do we need to close the response object if an error occurs ...
General concept is that when a function (or method) has multi return values one being an error , error should be checked first...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >
Python requests.Response Object - W3Schools
Property/Method Description apparent_encoding Try it Returns the apparent encoding close() Try it Closes the connection to the server content Try it Returns the content of the...
Read more >
Sending responses | Ktor
For example, with the enabled ContentNegotiation plugin, you can send a data object serialized in a specific format. The call.response property ...
Read more >
Request and response objects - Django documentation
So, for example, a header called X-Bender would be mapped to the META key HTTP_X_BENDER . Note that runserver strips all headers with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found