Mailchimp API V3 jQuery Ajax POST subscribers

There has been a big update on the Mailchimp API (v3.0) and many of the jQuery plugins are out of date in order to POST subscribers on form.submit().

After reading v3.0 docs:

Managing subscribers suggests the following JSON object format:

   "email_address": "", 
   "status": "subscribed", 
   "merge_fields": {
      "FNAME": "Urist", 
      "LNAME": "McVankab"

And the following root endpoint for the API lists resource:


So here’s my form.submit() code with the jQuery Ajax POST request:

    var mcForm = $('#mailchimpForm');
    var mailchimp = {};
    var url = '//' + mailchimp.dc + '' + + '/members/';

    function beginMailchimpPost(data){
        var params = JSON.stringify(data);
            url: url,
            method: 'POST',
            data: params,
            dataType: 'jsonp',
            contentType: 'application/json; charset=utf-8',
            error: function(res, text){
                console.log('Err', res);
            success: function(res){
                console.log('Success', res);

This is the JSON.stringify(data) object:

{"email_address":"","status":"subscribed","merge_fields":{"FNAME":"Name","LNAME":"Last name"}}

And I’m getting the following error:

GET http://... 401 (Unauthorized)
Err Object {readyState: 4, status: 404, statusText: "error"}

What could be wrong?

Here’s the link to Mailchimp’s API v3.0 docs (list members collection).

Source: ajax

1 Comment

  1. Aubrey Rhodes

    You’re getting the 401 because you’re not passing your API key with the request. Take a look at the getting started guide: You can use basic auth, by passing anything as the username and the api key as the password. explains how to use basic auth with a jquery ajax call like this.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.