added exception handling for the REST calls to server