https://kotlinlang.org logo
#ktor
Title
# ktor
t

Tony Blundell

09/25/2019, 3:53 PM
Hi, I’m using Ktor Client and MockEngine as per https://ktor.io/clients/http-client/testing.html. I’d like to check the request body that is being generated. How can I get the full body? I’ve tried request.body.toString() but that returns a concatenated version.
1
c

cy

09/25/2019, 3:59 PM
body
is an
OutgoingContent
that couldn't be stringified just like that. Try
request.body.toByteArray().toString(Charsets.UTF_8)
Note that depending on
OutgoingContent
kind, sometimes it could be consumed only once
t

Tony Blundell

09/25/2019, 4:01 PM
perfect, thanks!
3 Views