Wednesday, 14 January 2015

Asp.net HttpClient GET Method call API


public string getResponse()
        {
            string response= String.Empty;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BASE_URL);
                var result = client.GetAsync(API_URL).Result;
                response= result.Content.ReadAsStringAsync().Result;
            }
            return response;

        }


here BASE_URL is some thing like www.mastermoin.com

and API_URL is looking like /api/helloservice

No comments:

Post a Comment