I'm trying to receive status code with url calls.(Using grails)
def http = new HttpResponseDecorator(url)
// Authentication header
http.auth.basic(username, password)
// Http request method. Pulls out json file
http.request(Method.GET) {
response.success = {
render "Success!"
}
response.failure = { resp ->;
render resp
}
}
Trying this code snippet to receive make url calls, but I can't figure out how to pull out status code from this.
What I want to do is sending error messages depending on what status code I'm getting.(for example, 400 prints forbidden message of my choice)
Any suggestions for a class to receive status code of the GET calls?