Skip to content
REST client plugin that uses Spring's RestTemplate
Groovy Shell
Find file

Rest Client Builder Grails Plugin


Edit BuildConfig.groovy and add the following dependency:

compile ":rest-client-builder:1.0"

Basic Usage

Main entry point is the class. Construct and use one of the REST "verbs".

A GET request:

 def resp = rest.get("")

The response is a Spring ResponseEntity.

There are convenience methods for obtaining JSON:

  resp.json instanceof JSONObject == 'acegi'

And XML:

  resp.xml instanceof GPathResult == 'acegi'

POST and PUT requests

POST and PUT requests can be issued with the post and put methods respectively:

        def resp = rest.put(""){
            auth System.getProperty("artifactory.user"), System.getProperty("artifactory.pass")
            contentType "application/"
            json {
                name = "test-group"
                description = "A temporary test group"

In the example above the auth method performs HTTP basic auth, the contentType method sets the content type, and the json method constructs a JSON body.

Something went wrong with that request. Please try again.