Hi,
I’m trying to perform a PUT request through a scripted REST connector. There is documentation around how to add/change headers, connection timeouts, proxy etc. But couldn’t find a documentation on how to change the HTTP method. Is there any other recommended way of doing it?
The RESTClient (aka connection in the samples) is a groovyx.net.http.RESTClient
. You could use this method: HTTPBuilder#request
=> HTTPBuilder - http-builder 0.7.2 javadoc with this style:
def builder = new JsonBuilder(body_map)
result = connection.request(PUT, JSON) { req ->
uri.path = path
body = builder.toString()
response.success = { resp, json ->
new Uid(json._id, json._rev)
}
response.failure = { resp, json ->
// process the error
}
}
or you could directly use RESTClient#put
: RESTClient - http-builder 0.7.2 javadoc (which I have never used )
Regards
Patrick
2 Likes