Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestSharp - How do I get the numerical http response code?

Tags:

c#

http

restsharp

I'm using the RestSharp HTTP client library for C#.

How I would retrieve the actual numerical http response code? Not only do I not see a property containing the numerical code but I don't even see it in the headers collection.

like image 862
Howiecamp Avatar asked Jun 10 '15 19:06

Howiecamp


Video Answer


1 Answers

Simply grab the StatusCode property off of the RestResponse object and cast the enum value to int.

RestResponse response = client.Execute(request);
HttpStatusCode statusCode = response.StatusCode;
int numericStatusCode = (int)statusCode;
like image 199
David L Avatar answered Sep 21 '22 06:09

David L