Skip to content

Instantly share code, notes, and snippets.

@yaronguez
Created August 25, 2015 01:26
Show Gist options
  • Save yaronguez/36b02908590602ccb6b7 to your computer and use it in GitHub Desktop.
Save yaronguez/36b02908590602ccb6b7 to your computer and use it in GitHub Desktop.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace SSLTest
{
class Program
{
static void Main(string[] args)
{
var task = Tester();
Task.WaitAll(task);
Console.WriteLine("press any key to quit");
Console.ReadLine();
}
public static async Task Tester()
{
try
{
// Watch this var to see it's set to Tls | Ssl3
var temp = ServicePointManager.SecurityProtocol;
// Uncomment this line to correct error
// ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "[API KEY GOES HERE]");
var response = await client.GetAsync("https://us9.api.mailchimp.com/3.0/");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment