stupid question but how do I get the body of a fai...
# ktor
g
stupid question but how do I get the body of a failed request when using the ktor-client? E.g. The server logic looks like this:
Copy code
this.context.respond(status = HttpStatusCode.BadRequest, message = "My custom message")
But when performing a request with the ktor-client in a test I can't get that custom message
Copy code
val response = <http://client.post|client.post>("<http://localhost:8080/test>") { body = "invalidBody" } // If this returns a 400
response.readText() // I'm not able to receive the body "My custom message" from this readText()
d
You can get it from the exception or set
expectSucces
to false when creating the client.
g
@Dominaezzz ah ofc. Thanks!
Hm that didn't really work out. The expectSuccess is actually false by default so that's what I have running
ok nevermind, I forked up between using {} and () which was why my configuration wasn't applied