Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate int value from HttpStatusCode [duplicate]

Tags:

c#

Here I want to return integer like:

{
    "statusCode": "200"
} 

I am not getting statuscode as a integer.

var response = new HttpResponseMessage();
response.StatusCode = Request.CreateResponse((HttpStatusCode)200;
like image 963
venkat Avatar asked Jun 22 '16 08:06

venkat


1 Answers

public int DoHttpOperation(HttpClient client, parameters param)
{
    url = "url which you want to hit";
    client.DefaultRequestHeaders.Add("headername", "headervalue");
    var response = //operation which you want to perfrom GET/PUT/POST/DELETE
    return ((int)response.StatusCode);  //Here you will o/p 
}
like image 185
Sagar Avatar answered Nov 06 '22 03:11

Sagar