• Rest Client Builder plugin Grails

    Posted by Akash Sharma | Last Updated: 20-May-14

    Hi Guys.In this blog I am going to share some details of Rest Client Builder plugin in grails.

    This is my previous blog in which I used java core api for httpclient. In this blog I will demonstrate a similar type request functionality using Rest Client Builder plugin.


    Let say we have a request for a service in CURL as :

    curl -H "Content-Type: application/x-www-form-urlencoded" -X POST  -u myusername:mypassword -d '{"name":"davy jones" , "email":""}'


    Code in action-controller for using the service

    def restClientAction(){
    	String username="myusername"
    	String password="mypassword"
    	String restUrl=""
    	RestBuilder rest = new RestBuilder()
    	String auth=new StringBuffer(username).append(":").append(password).toString();
    	byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
    	String authHeader = "Basic "+new String(encodedAuth)
    	RestResponse resp = rest.put(restUrl) {
    		headers.'X-Stream' = 'true'
    		header 'AUTHORIZATION', authHeader
    			name = "davy jones"
    			email = ""
    	println "resp : "+resp.json
    	println "status : "+resp.getStatus()


    For more information on this plugin see this



    Akash Sharma


Tags: grails

Mobile Applications

Video Content

Bigdata & NoSQL

SaaS Applications



Alexa Certified Site Stats for