Dear all,
I have trying to use script runner to return an object value from a method called defined as below :
==> start script
import groovy.json.*
import groovyx.net.*
import groovyx.net.http.*
import static groovy.json.JsonOutput.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
import groovy.json.JsonSlurper
def AZAD_tenant_ID="xxxxxxxxxxx"
String targetUrl = 'https://login.microsoftonline.com/' + AZAD_tenant_ID +'/oauth2/token'
def http = new HTTPBuilder(targetUrl)
class ResultToken {
String token
String expiration
}
ResultToken getToken(){
ResultToken token
http.request(POST) {
requestContentType = URLENC
body = [
.....
]
response.success = { resp, json ->
token = new ResultToken(token: json["access_token"].toString(), expiration: json["expires_in"].toString())
}
}
}
//calling method to get token
def myToken=new ResultToken()
mytoken=getToken()
return mytoken.token
When I try to run my script in script runner console I have an exception error as below :
"groovy.lang.MissingPropertyException: No such property: http for class: Script359 at Script359.getToken(Script359.groovy:21) at Script359.run(Script359.groovy:41)"
Any idea how to solved ?
The object http in your script is of a type that doesn't have a getToken method. You'll need to look through the docs for the class to work out what it should be doing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.