MailChimp:提供的API密钥链接到不同的数据中心 [英] Mailchimp: The API key provided is linked to a different datacenter
本文介绍了MailChimp:提供的API密钥链接到不同的数据中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试update a Mailchimp list,但收到以下错误:
{
"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title":"Wrong Datacenter",
"status":403,
"detail":"The API key provided is linked to a different datacenter",
"instance":""
}
但是,我的请求URL中引用的数据中心(US14)与以我的API密钥为后缀的数据中心相同。
request.put({
url: 'https://us14.api.mailchimp.com/3.0/lists/xxxxxxxxx/members/',
auth: {
user: 'apikey:xxxxxxxxxxxxxxxxxxxxx-us14'
},
data: {
email_address: email,
status_if_new: 'subscribed',
email_type: 'html'
}
}
我已尝试生成新的API密钥,但无济于事(它们都在US14中)。
api
OK我首先通过headers
对象传递您的推荐答案密钥,从而使其正常工作。其次,我将数据包装在JSON.stringify
中,以确保MailChimp在POST时接收到正确的JSON对象。请看下面的示例代码,希望这对您有帮助:
request.post({
url: 'https://usXX.api.mailchimp.com/3.0/lists/xxxxxxx/members',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxxxxxx-usXX'
},
form: JSON.stringify({
email_address: req.body.email,
status: 'subscribed',
interests: { 'xxxxxxx': true } // Interest Group
})
}, function(err, httpResponse, body) {
res.send(body);
});
这篇关于MailChimp:提供的API密钥链接到不同的数据中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文