我正在尝试使用 Groovy HTTPBuilder 发送一个 POST,但我要发送的数据已经是 URL 编码的,所以我希望 HTTPBuilder 按原样发布它。我尝试了以下方法:
def validationString = "cmd=_notify-validate&" + postData
def http = new HTTPBuilder(grailsApplication.config.grails.paypal.server)
http.request(Method.POST) {
uri.path = "/"
body = validationString
requestContentType = ContentType.TEXT
response.success = { response ->
println response.statusLine
}
}
但它给了我一个 NullPointerException:
java.lang.NullPointerException
at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.setBody(HTTPBuilder.java:1200)