Skip to content

Instantly share code, notes, and snippets.

@rbe
Created May 29, 2012 11:38
Show Gist options
  • Select an option

  • Save rbe/2827975 to your computer and use it in GitHub Desktop.

Select an option

Save rbe/2827975 to your computer and use it in GitHub Desktop.
Groovy HTTP POST
@Grab(group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.5.0')
import groovyx.net.http.*
def postBody = new File('req.xml').text
def http = new HTTPBuilder('http://localhost:8080/odisee/document/generate')
try {
http.post(path: "generate", body: postBody, requestContentType: groovyx.net.http.ContentType.XML) { resp ->
assert resp.statusLine.statusCode == 200
println resp.statusLine
}
} catch (e) {
println e
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment