Is there a way to handle http status code 422 gracefully. I am looking for the best practice here. I know that HttpStatusCode is an enum so what i tried is this,
HttpStatusCode Unprocessable = (HttpStatusCode)422; if (Response == (HttpStatusCode)422)
but does not allow me to compare it. Am i doing something wrong here?
Whats the best possible way to add this status code at runtime.
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.. }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With