Reputation: 44919
I have a class that uses the HTTPBuilder library for Groovy. I got this error:
Class
groovy.lang.MissingPropertyException
Message
No such property:
data for class: groovyx.net.http.HTTPBuilder$RequestConfigDelegate
What does it mean?
Here is the code:
def myService = new HTTPBuilder("http://example.com")
myService.request(POST) {
uri.path = "/myservice/"
requestContentType = JSON
body = [ parameter1 : value1, parameter2: value2]
headers = [From: "header:myheader"]
response.success = { resp, data ->
if(!data.completed) {
render(contentType: "text/json") { success = false }
}
render(contentType: "text/json") { success = data.completed }
}
response.failure = { resp ->
if(!data.completed) {
render(contentType: "text/json") { success = false }
}
render(contentType: "text/json") { success = data.completed }
}
}
Upvotes: 0
Views: 3639
Reputation: 9868
From what I can see, you are not declaring the data
in the response.failure
closure but trying to refer it. Try the following block:
response.failure = { resp, data ->
if(!data.completed) {
render(contentType: "text/json") { success = false }
}
render(contentType: "text/json") { success = data.completed }
}
Upvotes: 1