我有以下调用来发布订阅 Mailchimp 列表,但它返回未经授权。我在 web.config 中存储了 API 密钥、列表和用户名,并对其进行了三次检查。
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);
}