HttpClient client = new HttpClient(); string authInfo = "raj" + ":" + "34sddff"; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo); client.BaseAddress = new Uri("http://sample"); HttpResponseMessage response = client.GetAsync(url).ContinueWith(task => task.Result).Result; // Parse the response body. Blocking! if (response.IsSuccessStatusCode) { var httpResponseResult = response.Content.ReadAsStringAsync().ContinueWith(task => task.Result).Result; var data = JObject.Parse(httpResponseResult); var responseCode= data.SelectToken("code").Value(); var message = data.SelectToken("message").Value(); }
.Result
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)