throw an BadResponseException if the request is not successful