【问题标题】:Mailchimp: The API key provided is linked to a different datacenterMailchimp:提供的 API 密钥链接到不同的数据中心
【发布时间】:2017-06-07 05:30:20
【问题描述】:

我正在尝试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 中引用的数据中心与我的 API 密钥后缀相同 (us14)。

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 playground 测试过相同的 API 密钥?如果是这样,它有效吗?
  • 是的,确实如此。 @ekad
  • 我遇到了同样的问题。对于他们的 API 和文档非常糟糕的 mailchimp 有多棒。浪费这么多时间做一件基本的事情。

标签: node.js mailchimp mailchimp-api-v3.0


【解决方案1】:

好的,我首先通过 headers 对象传递您的 API 密钥来实现此功能。其次,我将我的数据包装在 JSON.stringify 中,以确保 MailChimp 在发布时收到正确的 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);
});

【讨论】:

    【解决方案2】:
    const options = {
        method: "POST",
        auth: "uname:apikey656a******d2dfdb37c071a7cc-us19" //Should not give a space after a colon after uname
      }
    

    我在 uname 的冒号后面加了一个空格。现在 API 工作正常

    【讨论】:

      猜你喜欢
      • 2017-12-21
      • 2019-02-26
      • 2020-01-31
      • 2014-05-23
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-22
      相关资源
      最近更新 更多