Reputation: 113
I have the following code snipet
class **ResultToken** {
String token
String expiration
}
// HTTP post request to retrive active token
// Return : ResultToken object
ResultToken getToken(){
ResultToken token
http.request(POST) {
...
response.success = { resp, json ->
token = new ResultToken(token: json["access_token"].toString(),
expiration: json["expires_in"].toString())
}
}
token
}
def tokenValue =getToken().token
return tokenValue
Exception error : groovy.lang.MissingPropertyException: No such property: http for class: Script259 at Script259.getToken(Script259.groovy:21) at Script259.run(Script259.groovy:41)
Any idea?
regards
Upvotes: 0
Views: 224
Reputation: 20699
This way you define the handler which doesn't return anything usefull.
It should rather be:
ResultToken getToken(){
ResultToken token
http.request(POST) {
....
response.success = { resp, json ->
token = new ResultToken(token: json.access_token, expiration: json.expires_in)
}
}
token
}
Upvotes: 1