我正在使用 groovy RESTClient 0.6 发出 POST 请求。我希望响应中有一个 XML 有效负载。我有以下代码:
def restclient = new RESTClient('<some URL>')
def headers= ["Content-Type": "application/xml"]
def body= getClass().getResource("/new_resource.xml").text
/*
If I omit the closure from the following line of code
RESTClient blows up with an NPE..BUG?
*/
def response = restclient.post(
path:'/myresource', headers:headers, body:body){it}
println response.status //prints correct response code
println response.headers['Content-Length']//prints 225
println response.data //Always null?!
response.data 始终为空,即使当我使用 Google chrome 的邮递员客户端尝试相同的请求时,我也会返回预期的响应正文。这是 RESTClient 的已知问题吗?