我在连接到新的 MailChimp 3.0 API 时遇到问题(2.0 可以正常工作)。
我想发送一些订阅者。我究竟做错了什么?我可能试图以apikey
错误的方式发送(HTTP 基本身份验证)。文档在这里,但我无法使其工作: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);
}