I have a problem connecting to the new MailChimp 3.0 API (2.0 works fine).
I would like to send some subscriber. What am I doing wrong? I am probably trying to send the apikey
in the wrong way (HTTP Basic authentication). The documentation is here but I am not able to make it work: http://developer.mailchimp.com/documentation/mailchimp/guides/get-started-with-mailchimp-api-3/.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://us12.api.mailchimp.com/3.0/lists/<listnumber>/members/");
string json = @"
{
""email_address"": ""test@test.com"",
""status"": ""subscribed"",
""merge_fields"": {
""FNAME"": ""Urist"",
""LNAME"": ""McVankab""
}
}
";
byte[] data = Encoding.UTF8.GetBytes(json);
request.Method = "POST";
request.Headers.Add("user", "<mykeynumber>");
request.ContentType = "application/json";
request.ContentLength = data.Length;
using (System.IO.Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}