C# HttpClient and HttpWebRequest can both get the job done.
The following example use Basic authentication, which requires to convert username & password into a string token and embed in the http header.
The conversion simply concatenates the username and password with colon as delimiter and convert it to ascii bytes.
using System.Net;
HttpClient client = new HttpClient();
byte[] byteArray = Encoding.ASCII.GetBytes("username:password");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html"));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//Async call to the api
HttpResponseMessage response = await client.GetAsync("http://testapi.com.au/api");
HttpContent content = response.Content;
//check status code
Console.WriteLine("Response StatusCode: " + (int)response.StatusCode);
//read the string.
string result = await content.ReadAsStringAsync();
The httpclient method use GetAsync for GET method and PostAsync for POST method.
The HttpWebRequest method is similar.
using System.Net;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://testapi.com.au/api");
request.Method = "GET";
String token = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("username:password"));
request.Headers["Authorization"] = "Basic" + " " + token;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream()
//...read from the stream for the content
The result returned from the service call is normally Jason or Xml string. Just convert it to anything you need.