How do I call a RESTful service and pass in basic auth. This is username and password along with authorization basic.
using (var httpClient = new HttpClient())
{
//var request = new StringContent(messageBody);
//request.Headers.ContentType = new MediaTypeHeaderValue("application/json");
httpClient.BaseAddress = new Uri(serviceUrl);
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var credentials = Encoding.ASCII.GetBytes("myadmin:mypassword");
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials));
//var response = await httpClient.PostAsJsonAsync(serviceUrl, customer);
HttpResponseMessage response = await httpClient.PostAsJsonAsync("url here", customer);
}