I\'m building an HTTP API client using RestSharp, and I\'ve noticed that when the server returns an HTTP error code (401 Unauthorized, 404 Not Found, 500 Internal Server Err
RestSharp has added boolean property IRestResponse.IsSuccessful
which covers your use case. I couldn't find any documentation referring to this property, but here's the line that defines the property's method.
Interesting to note is that RestSharp considers codes 200-299 to be successful, while CodeCaster considers codes 200-399 to be successful.