【问题标题】:Error 400 on trying to add a contact in mailchimp尝试在 mailchimp 中添加联系人时出现错误 400
【发布时间】:2019-10-19 22:35:34
【问题描述】:

我在尝试调用 mailchimp API V3 以将新联系人添加到我的列表时收到此错误

"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. For field-specific details, see the \'errors\' array.","instance":"f8b79d9b-1c02-4062-a0e4-847e31f7bd61","errors":[{"field":"","message":"Schema describes object, NULL found instead"}]}'

这里是使用的代码:

app.post("/", function(req,res){
var email = req.body.email;

var data = {
    members : [
        {
            email_address: email,
            status: "subscribed"
        }
    ]
};

var jsonData = JSON.stringify(data);

var options = {
    headers :{
        'Authorization': 'thomas APIKEY',
        'Content-Type': 'application/json',
        'Content-Length': jsonData.length
    },
    url: "https://us20.api.mailchimp.com/3.0/lists",
    method: "POST",
    data:jsonData
};

console.log(options);

request(options, function(error, response, body){
    if(error)
    {
        console.log(error);
    }
    else{
        console.log(response);
    }
})

我尝试将 /Listkey/members 添加到我的网址,但没有成功

你有什么建议吗?谢谢

【问题讨论】:

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


    【解决方案1】:

    我找到了解决方案,传递给 request 的元素不好。 这是功能代码:

    app.post("/", function(req,res){
      var email = req.body.email;
    
      var data = {
        "email_address": email,
        "status" : "subscribed"
      };
    
    
      var options = {
        "url": "https://us20.api.mailchimp.com/3.0/lists/c9b9a6e109/members/",
        "method": "POST",
        "headers": {
            "Authorization": "thomas APIKEY"
        },
        "body": data,
        "json": true
      };
    })
    

    【讨论】:

      猜你喜欢
      • 2011-12-07
      • 1970-01-01
      • 2014-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-09
      • 2019-05-20
      • 1970-01-01
      相关资源
      最近更新 更多