System.Net HttpStatusCode class does not have code 422

I was using RestSharp which returns the server response status code in a property of type HttStatusCode and I needed to check for a 422 response myself but the of course the type doesn’t include it. Fortunately I was still able to test using the following:

if(response.StatusCode == (HttpStatusCode)422)
{
    // Do my stuff..
}

Leave a Comment