Recording parsed responses from httpPost() via log.debug() in a useful format

How can I serialize or otherwise transform the parsed result of httpPost() calls so that the content is fully represented in the log and can be more useful in debugging?

I have the following code in a driver:

        httpPost( [uri: uri, path: '/1Wire/Search.html', body: body, requestContentType: 'application/x-www-form-urlencoded'] ) { resp ->
            if (resp.success) {
                processSensors(resp.data)
            }
            if (logEnable)
                if (resp.data) log.debug "${resp.data}"
        } 

Currently, the log.debug() call results in some text from the parsed response, but it does not show the pretty form of the parser response:

Try

log.debug "${resp.data.dump()}"

or just

log.debug resp.data.dump()
1 Like

Thanks for the follow-up. It's a little bit better, but it still appears to be missing some of the data that is in the response:

1 Like

Is the response in XML? If so it could just not be formatting properly because if that. You can try escape it and see if it gives you something better.

1 Like