using System; using System.Text; using System.IO; using System.Net.Http; using System.Collections.Generic; namespace fn_dotnet_examples { class Program { private static string url = "https://test.factorsnetwork.com/api/debtors.json"; private static string username = "USERNAME"; private static string password = "PASSWORD"; static void Main(string[] args) { HttpResponseMessage message; var authContent = Convert.ToBase64String(Encoding.Default.GetBytes(username + ":" + password)); using (HttpClient client = new HttpClient()) using (var content = new FormUrlEncodedContent(new KeyValuePair[] { new KeyValuePair ("companyName", "Test Inc."), new KeyValuePair ("city", "JOLIET") })) { var queryString = content.ReadAsStringAsync().Result; UriBuilder builder = new UriBuilder(url); builder.Query = queryString; client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authContent); var response = client.GetAsync(builder.ToString()); message = response.Result; } Console.WriteLine(message.IsSuccessStatusCode); if (message.IsSuccessStatusCode) { Console.WriteLine(message.Content.ReadAsStringAsync().Result); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); } } }