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
Dominaezzz
12/03/2019, 6:00 PM
You can get it from the exception or set
expectSucces
to false when creating the client.
g
gotoOla
12/03/2019, 6:55 PM
@Dominaezzz ah ofc. Thanks!
gotoOla
12/04/2019, 8:56 AM
Hm that didn't really work out. The expectSuccess is actually false by default so that's what I have running
gotoOla
12/04/2019, 9:28 AM
ok nevermind, I forked up between using {} and () which was why my configuration wasn't applied