Hello,
Here you go..
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.TEXT
import groovyx.net.http.HTTPBuilder
def http = new HTTPBuilder('
http://URL')
ERROR is caught here --> http.request( Method.GET, ContentType.TEXT ) { req ->
uri.path = '/some-path'
headers.Accept = 'application/json'
headers.ClientRoles = 'ROLES'
headers.Authorization = 'Auth code'
response.success = { resp, reader ->
println "Got response: ${resp.statusLine}"
println "Content-Type: ${resp.headers.'Content-Type'}"
print reader.text
}
}
ERROR :
Caught: groovy.lang.MissingPropertyException: No such property: Method for class: RestCall
groovy.lang.MissingPropertyException: No such property: Method for class: RestCall
at RestCall.run(RestCall.groovy:27)
------------------------------------------------------------------------------------------------------------------------------------
LINE 43 : new HTTPBuilder('
http://www.google.com/').request(GET) { req ->
response.success = { resp ->
println 'request was successful'
assert resp.status < 400
}
response.failure = { resp ->
println 'request failed'
assert resp.status >= 400
}
}
Caught: groovy.lang.MissingMethodException: No signature of method: groovyx.net.http.HTTPBuilder.request() is applicable for argument types: (groovyx.net.http.Method, RestCall$_run_closure1) values: [GET, RestCall$_run_closure1@38bdc9b3]
Possible solutions: request(groovyx.net.http.Method, groovy.lang.Closure), request(groovyx.net.http.Method, java.lang.Object, groovy.lang.Closure), request(java.lang.Object, groovyx.net.http.Method, java.lang.Object, groovy.lang.Closure)
groovy.lang.MissingMethodException: No signature of method: groovyx.net.http.HTTPBuilder.request() is applicable for argument types: (groovyx.net.http.Method, RestCall$_run_closure1) values: [GET, RestCall$_run_closure1@38bdc9b3]
Possible solutions: request(groovyx.net.http.Method, groovy.lang.Closure), request(groovyx.net.http.Method, java.lang.Object, groovy.lang.Closure), request(java.lang.Object, groovyx.net.http.Method, java.lang.Object, groovy.lang.Closure)
at RestCall.run(RestCall.groovy:43)
-Thanks,
Parth.
---------------------------------------------------------------------------------------------------------------------------------------