連接到新的MailChimp 3.0 API(2.0正常工作)時出現問題。與MailChimp v3.0的連接API
我想寄一些訂戶。我究竟做錯了什麼?我可能試圖以錯誤的方式發送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"": ""[email protected]"",
""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);
}
你看到了什麼樣的錯誤? – Mateo