Skip to content

Instantly share code, notes, and snippets.

@danhyun
Last active August 29, 2015 13:57
Show Gist options
  • Save danhyun/9670589 to your computer and use it in GitHub Desktop.
Save danhyun/9670589 to your computer and use it in GitHub Desktop.
fast and easy restclient
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient
def apiUrl = 'http://localhost:8888'
def api = new RESTClient(apiUrl, ContentType.JSON)
api.headers = ['auth-key': '11', 'Accept': 'application/json; q=0.9,*/*; q=0.8']
def id = 20784
println api.get(path: "/user/$id").data
println api.put(path: "/user/$id/updatePassword",
body: [
UpdateUserPassword: [password: 123]
]).data
println api.get(path: "/user/$id").data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment