I'm trying to use MailChimp API in an C# application.
I'm able to successfully use hurl.it to get the correct response so I know that it works.
I'm now trying to do this programmatically and cannot seem to either get it to work or know how to get the response and read it.
MailChimp always returns Json.
Here is the code I have so far:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://us10.api.mailchimp.com/3.0/Lists");
String username = "anystring";
String password = "my-api-key";
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
request.Headers.Add("Authorization", "Basic " + encoded);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
var rs = response.GetResponseStream();
Now when I use hurl.it
it returns correctly:
{
"lists": [{
"id": "64df5g6h2",
"name": "Agent List",
"contact": {
"company": "Test Agent",
"address1": "123 Test Street",
"address2": "",
"city": "City",
"state": "Ut",
"zip": "84065",
"country": "US",
"phone": ""
}
}]
}
I'm stuck on how I can retrieve this same data through my code above? I'm not currently able to use any third-party libraries unless they are a part of the GAC, so no NuGet packages etc. It adds a layer of complication since I have to add them to the GAC to use them.