fix exception if response is not successful

updade get_resource method