Issuing a REST request and parsing a response
A proper introduction to REST is out of scope for this recipe. Countless materials describing the REST architectural style are available both online and offline. Wikipedia's entry on Representational State Transfer at http://en.wikipedia.org/wiki/Representational_State_Transfer provides a compact description of REST's main concepts, its limits, and the guiding principles to design RESTful applications. A more tongue-in-cheek introduction to REST can be found on Ryan Tomayko's website at http://tomayko.com/writings/rest-to-my-wife.
There are several ways to execute a REST request using Groovy. In this recipe, we are going to show how to execute a GET
operation against a RESTful resource using RESTClient
from the HTTPBuilder
project (http://groovy.codehaus.org/modules/http-builder/doc/index.html). HTTPBuilder
is a wrapper for Apache HttpClient
, with some Groovy syntactical sugar thrown on top.
Getting ready
For this recipe, we will use the RESTful...