The REST Client of HTTP Builder returns a HttpResponseDecorator. How can I get the raw response out of it (for logging purposes)?
EDIT (some code might be handy):
withRest(uri: domainName) {
def response = post(path: 'wsPath', query: [q:'test'])
if (!response.success) {
log.error "API call failed. HTTP status: $response.status"
// I want to log raw response and URL constructed here
}
I've been having a nightmare with the same problem. Here's my solution using HTTPBuilder:-
response.failure = {resp ->
println "request failed with status ${resp.status}, response body was [${resp.entity.content.text}]"
return null
}
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With