I have my own Web API application in which i want to call the another api which is on server. How can i do that ?
var result = url(http://54.193.102.251/CBR/api/User?EmpID=1&ClientID=4&Status=true);
// Something like this.
I have my own Web API application in which i want to call the another api which is on server. How can i do that ?
var result = url(http://54.193.102.251/CBR/api/User?EmpID=1&ClientID=4&Status=true);
// Something like this.
You can use HttpClient
. Here is a sample of async
method which calls your API:
var client = new HttpClient();
client.BaseAddress = new Uri("http://54.193.102.251/CBR/api");
// here you can add additional information like authorization or accept headers
client.DefaultRequestHeaders
.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// you can chose which http method to use
var response = await client.GetAsync("User?EmpID=1&ClientID=4&Status=true");
if (!response.IsSuccessStatusCode)
return; // process error response here
var json = await response.Content.ReadAsStringAsync(); // assume your API supports json
// deserialize json here