Having some problems reading responses from RESTClient where I keep running into errors like:
groovy.lang.MissingMethodException: No signature of method: groovyx.net.http.RESTClient.put() is applicable for argument types: (java.util.LinkedHashMap, ConsoleScript5$_run_closure1) values: [[path:foo/bar/baz, query:[format:xml], body:[description:], requestContentType:application/x-www-form-urlencoded], ConsoleScript5$_run_closure1@1441b16]
e.g.
<code>
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0' )
api.auth.basic 'scott', 'tiger'
def resp = api.put(path: "foo/bar/baz",
query: [format: 'xml'],
body: [description: ''],
requestContentType: groovyx.net.http.ContentType.URLENC) { resp, xml ->
assert resp.status==201
def result = new groovy.xml.StreamingMarkupBuilder().bindNode(xml).toString()
}
</code>
In this case I'm trying to read from a PUT although I've used very similar code elsewhere to read from the get method. I'm kinda confused as to what the syntax is doing. The resp return value is a HttpResponseDecorator I guess, but I dont know quite where xml is coming from is HttpResponseDecorator also a closure of some kind? I dont see an xml property on it?
I've also been getting "No signature of method: groovyx.net.http.RESTClient.get() is applicable for argument types" errors on similarly formed RESTClient.get methods via the dev snapshot of GR-ECLIPSE, while the same code would work in GroovyConsole or JetGroovy.. None of which will run the put() example above BTW.
Guess I'm after a little understanding as to how the read what the RESTClient methods are doing/returning and how to square that with HttpBuilders JavaDocs. Or if I'm doing something stupid - thats more than possible too.
- Richard