Closed Lucas-C closed 7 years ago
You can do something like this:
def failure = { resp ->
resp.entity.writeTo(System.out)
println resp.statusLine.statusCode.toString()
}
Not the easiest, but it works.
I think that resp.entity is a BasicHttpEntity , but you can check that. writeTo() takes any OutputStream.
Awesome, thanks ! I did this :
def failure = { resp ->
def outputStream = new ByteArrayOutputStream()
resp.entity.writeTo(outputStream)
def errorMsg = outputStream.toString('utf8')
}
Hi.
I had a look at what HttpResponseDecorator contains, but I don't see how to get the response body in case of a non-200 HTTP status :
What I see is that
data
isnull
.This is very limitating to bubble up error messages from HTTP services.
Is there a way to extract the JSON from
getpostman.com
response in this example ?Regards.