using System;
using System.Text;
using System.Net.Http;
using System.IO;
using System.Collections.Generic;
namespace fn_dotnet_examples
{
class Program
{
private static string url = "https://test.factorsnetwork.com/api/creditors.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")
}))
{
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authContent);
var response = client.PostAsync(url, content);
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();
}
}
}