public IEnumerable<T> Get() { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(_endpoint); //Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // call the REST method HttpResponseMessage response = client.GetAsync(MethodURL).Result; // Blocking call! if (response.IsSuccessStatusCode) { // Parse the response body. Blocking! return response.Content.ReadAsAsync<IEnumerable<T>>().Result; } else { throw new Exception(string.Format("Data access faild,{0} ({1}) method:{2}", (int)response.StatusCode, response.ReasonPhrase, MethodURL)); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)