【问题标题】:Unknown Method Error - Code: -99 on Mandrill users/ping.json未知方法错误 - Mandrill 用户/ping.json 上的代码:-99
【发布时间】:2013-06-04 20:47:21
【问题描述】:

我有以下代码:

var temp = { 'key': '***.....zWw' };
$.ajax({ 
url: 'https://mandrillapp.com/api/1.0/users/ping.json.',
type: 'POST',
data: temp,

success: function(result) {
    console.log(result);
}
});

这是回应:

{"status":"error","code":-99,"name":"UserError","message":"Unknownmethod\"users.ping.json\""}

我在网上搜索,我找不到这个错误,所以我只能猜测我做错了什么,很简单。

我已经删除并添加了新的密钥,我也试过了,但仍然是这个错误。

我也看过 Google 讨论,但那里没有乐趣。

有人有想法吗?

【问题讨论】:

  • 确认你使用的host url是否正确,我发现json后面有个句号,可能会报错

标签: jquery ajax mandrill


【解决方案1】:

我很傻,在 ajax POST 的 url 部分有一个句号。我认为这会很好,对于其他正在苦苦挣扎的人,我会提供完整的脚本信息。

var template = { "key": "thn*****ghjh7ghj7", "template_name": "validateEmail",        "template_content": [{ "name": "example name","content": "example content" }],
"message": {
    "html": "something",
    "text": "somethingfg",
    "subject": "Email Validation",
    "from_email": "noreply@example.org",
    "from_name": "Some User",
    "to": [{"email": email,"name": "Recipient Name"}],
    "headers": {"Reply-To": "noreply@example.org"},
     "global_merge_vars": [
        {
            "name": "EMAILVALIDATE",
            "content": validateEmailURL,
        }
    ],
},
"async": false,
"ip_pool": "Main Pool"
};

$.ajax({ 
url: 'https://mandrillapp.com/api/1.0/messages/send-template.json',
type: 'POST',
data: template,

success: function(result) {
    console.log(result);
}
});

上面的代码,发送一个在 MailChimp 中创建并发送过 Mandrill 的电子邮件模板。由于这是一个验证,我只需要放置一个 merg_tag,它会发送 url 进行验证。

大部分时间都花在这上面,因为对于那些刚接触 API 和事物的人来说,我发现这些信息并不是那么好。

希望这可以帮助将来的人!

【讨论】:

    猜你喜欢
    • 2011-02-23
    • 2011-02-22
    • 2015-03-18
    • 1970-01-01
    • 2018-08-06
    • 2011-11-12
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多