In the example below, I need to pass a login / password pair because the REST service requires Basic Authentication. So how do I pass this information in the following section? (Additional information: authentication must be made encoded in the send header)
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://dominio:9000/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// New code:
HttpResponseMessage response = await client.GetAsync("api/products/1");
if (response.IsSuccessStatusCode)
{
Product product = await response.Content.ReadAsAsync>Product>();
Console.WriteLine("{0}\t${1}\t{2}", product.Name, product.Price, product.Category);
}
}