Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the raw response and URL from HttpResponseDecorator

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
        }
like image 224
zoran119 Avatar asked Apr 19 '13 01:04

zoran119


1 Answers

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!

like image 90
mekondelta Avatar answered Oct 06 '22 03:10

mekondelta