Thursday, May 31, 2018

Consuming Api using WebClient

 https://www.c-sharpcorner.com/article/creating-web-api-and-consuming-in-console-application-using-web-client-in-a-sync/



 string Baseurl = "https://localhost:223002/";
 public void GetAllEmployeeData() //Get All Events Records  
        {
            List<Employee> APIresult = new List<Employee>();
            using (var client = new WebClient()) //WebClient  
            {
                client.Headers.Add("Content-Type:application/json"); //Content-Type  
                client.Headers.Add("Accept:application/json");
                var result = client.DownloadString(Baseurl + "api/AcServices/GetEmployeeData"); //URI  
                APIresult = JsonConvert.DeserializeObject<List<Employee>>(result);
            }
        }

No comments:

Post a Comment

javascript Filter/index off

 var family = [{"name":"Jack",  "age": 26},               {"name":"Jill",  "age"...