<dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.7.1</version>
</dependency>
groovy
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
groovy
def http = new HTTPBuilder('http://example.com')
groovy
http.setHeaders('Content-Type': 'application/json', 'Authorization': 'Bearer token')
http.setQuery([param1: 'value1', param2: 'value2'])
groovy
http.request(GET, JSON) { req ->
response.success = { resp, body ->
println "Response status: ${resp.statusLine}"
println "Response body: ${body}"
}
response.failure = { resp, body ->
println "Request failed: ${resp.statusLine}"
println "Response body: ${body}"
}
}