5
What to do when class HttpStatusCode
there is no code 207, 208 and 226 ?
Someone already asked the question on Github: https://github.com/dotnet/corefx/issues/4382, I don’t think they did an "update". Follows code:
HttpResponseMessage response = await httpClient.PostAsync();
if ((int)response.StatusCode < 200 || (int)response.StatusCode > 226 && (int)response.StatusCode != 404) //[200,208] = HTTP OK
{
//HTTP Response Not OK
}
In the above code you can only enter the if
when it is different from the list below.
Here is the list of the family "Success":
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 226
List source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#Respostas_de_sucesso
What is your doubt? if Httpstatuscode does not exist or how to validate it ? your question has become very vague
– Marcos Brinner
@Marcosbrinner If code comes
207
, will generate the right exception ? How can I treat this ?– Matheus Miranda
@Marcosbrinner can only enter the
if
different from 200 to 226.– Matheus Miranda
What exactly is happening and what you are trying to do?
– Leandro Angelo
@Leandroangelo I am consuming API that can return the 3 codes above (207, 208 and 226). Look at my logic, which is saying that can only enter the
if
different from 200 to 226, but there is no such 3 codes, what to do ?– Matheus Miranda
I mean, you can only enter
if
when it was not of the family "Success" !– Matheus Miranda