Created
October 14, 2011 14:23
-
-
Save farito/1287254 to your computer and use it in GitHub Desktop.
Llamada a api
This file contains hidden or 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
def getItemApi(String item){ | |
RESTClient rest = new RESTClient() | |
Object resp = rest.get([uri: "http://ec2-67-202-25-72.compute-1.amazonaws.com:8080", path : '/items/MLA123456', contentType : JSON]) | |
println resp.getStatus() | |
int size = resp.responseData.available(); | |
char[] theChars = new char[size]; | |
byte[] bytes = new byte[size]; | |
resp.responseData.read(bytes, 0, size); | |
for (int i = 0; i < size;) | |
theChars[i] = (char)(bytes[i++]&0xff); | |
String result = new String(theChars); | |
println result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment