1
我有以下調用來發布訂閱到Mailchimp列表,但它返回未授權。我有存儲在web.config中的API密鑰,列表和用戶名,我有三重檢查。向MailChimp API v3發送請求總是返回未授權
using (var wc = new System.Net.WebClient())
{
string parameters = string.Concat("email_address=", email, "&status=", "subscribed"),
url = "https://us12.api.mailchimp.com/3.0/lists/" + ConfigurationManager.AppSettings["MailChimp.ListId"] + "/members";
wc.Headers.Add("Content-Type", "application/json");
wc.Credentials = new NetworkCredential("", ConfigurationManager.AppSettings["MailChimp.ApiKey"]);
string result = wc.UploadString(url, parameters);
}
這完美地工作。感謝堆門 – Andrew