0

I have the following code:

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);
}
});

And this is the response:

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

I have search online, and I am unable to find this error, so I can only guess I have done something incorrect which is simple.

I have removed and added new Keys, and i have tried alsorts, but still this error.

I have looked on Google Discussions also, but no joy there.

Anyone have an idea ?

Andrew Walker
  • 492
  • 1
  • 5
  • 23
  • make sure that the host url you are using is correct or not and i found there is a full stop after json,it may gives error – fresher Jul 21 '14 at 09:08

1 Answers1

0

Silly sod that I am, in the url part of the ajax POST there is a fullstop. I thought it would be good, for anyone else that is struggling I provide full script info.

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);
}
});

the above code, sends an email template created in MailChimp and sent too Mandrill. As this is a validation, all I needed was to put one merg_tag, which sends the url to validate.

Spent most of the day on this, because for someone thats new to API's and things, I found the information not all that great.

Hope this can help someone in the future!

Andrew Walker
  • 492
  • 1
  • 5
  • 23