Last active
August 29, 2015 13:57
-
-
Save danhyun/9670589 to your computer and use it in GitHub Desktop.
fast and easy restclient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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