zor*_*119 10 groovy httpresponse httpbuilder
在REST客户端的HTTP生成器返回HttpResponseDecorator.如何从中获取原始响应(用于记录目的)?
编辑(一些代码可能很方便):
    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
        }
小智 12
我一直在做同样问题的噩梦.这是我使用HTTPBuilder的解决方案: -
response.failure = {resp ->
    println "request failed with status ${resp.status}, response body was [${resp.entity.content.text}]"
    return null
}
希望有所帮助!
| 归档时间: | 
 | 
| 查看次数: | 7936 次 | 
| 最近记录: |