This does not always catch all errors. As Jacob said, it ResponseStatuscan be Completed, even if it returns 404 or some other bad status.
Instead, use one StatusCodethat processes all responses HttpStatus.
if (response.StatusCode != System.Net.HttpStatusCode.OK)
throw new ApplicationException(response.ErrorMessage);
source
share