Server returned a fault exception: [104] Invalid Mailchimp API Key. Acessing Wrong Datacenter

497 views
Skip to first unread message

Misha Developer

unread,
Nov 1, 2012, 2:49:18 AM11/1/12
to mailchimp-...@googlegroups.com
Hello Dear, I m Using MailChimpAspNet.dll version 1.0.0.0 and  CookComputing.XmlRpcV2.dll.

Now adding both this dll my code in ASP.NET 4.0 application. It works fine. but the prob is when

I hv a class named IMailChimp.cs file with the code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CookComputing.XmlRpc;
using MailChimpAspNet.MailChimpSubscribe;


namespace MailChimpAspNet.MailChimpSubscribe
{
    [XmlRpcUrl("http://us1.api.mailchimp.com/1.3/")]//analoga me to apikey ( http://apidocs.mailchimp.com/rtfm )
    public interface IMailChimp
    {
        [XmlRpcMethod("listSubscribe")]
        bool listSubscribe(string apikey, string id, string email_address,string [] merge_vars,string email_type="html",
            bool double_optin=false,bool replace_interests=true,bool send_welcome=false);

        [XmlRpcMethod("listUnsubscribe")]
        bool listUnsubscribe(string apikey, string id, string email_address, bool delete_menber=false,
        bool send_goodbye=true, bool send_notify=true);
                           
    }
}


i my code behind page.. at the button click event:

protected void btnsubscribe_Click(object sender, EventArgs e)
    {
        IMailChimp mailchimp = (IMailChimp)XmlRpcProxyGen.Create(typeof(IMailChimp));
        try
        {
            string[] merge_vars = new string[1];
            merge_vars[0] = txtsubscribeEmail.Value;
           bool ok = mailchimp.listSubscribe("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us1", "xxxxxxxxxx", txtsubscribeEmail.Value, merge_vars, "html", false, true, true);
         
            if (ok)
            {
                initSub();
                lblresult.Visible = true;
                Utility.clsUtility.setFansyMessage(lblresult, "Success", "Your Email ID has been Successfully Subscribed.");
                txtsubscribeEmail.Value = "";
                txtsubscribeName.Value = "";
            }

            else
            {
                lblresult.Visible = true;
                Utility.clsUtility.setFansyMessage(lblresult, "Fail", "Email Error!");
            }
        }

            //Response.Redirect("MailChimpSub.aspx?EmailID=" + txtsubscribeEmail.Value.ToString());

        catch (Exception ex)
        {
            lblresult.Text = ex.Message;
        }

    }

Now, On Compling and running and debbugging..
I get the Exception:

Server returned a fault exception: [104] Invalid Mailchimp API Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us1 . You are accessing the wrong datacenter - your client library may not properly support our datacenter mapping scheme.

what the hell is this.!! now wait wait wait...

I hv another mail chimp acc. in that using its api key. it works perfect in this above demo code.. now pls Can anyone let me know why such stuff happen.
Is this due to datacenter.. if you say yes then. i wud let u knw that without giving datacenter. and using my another mailchimp acc. api key works perfect(-us6).. but using my original acc.(-us1). and i only want to use my -us1 acc. apikey.. but which is giving me the above mentioned exception..

Let me know ASAP the solution that y this exception coming from m waiting. Thnx in advnce dear..



jesse

unread,
Nov 1, 2012, 6:13:27 AM11/1/12
to mailchimp-...@googlegroups.com
You've not followed the documentation relating to setting proper API endpoints:
http://apidocs.mailchimp.com/api/rtfm/

And you must use an API key attached to the account you wish to access.


jesse

Misha Developer

unread,
Nov 1, 2012, 8:55:04 AM11/1/12
to mailchimp-...@googlegroups.com
Heya i hv viewed all those.. but still not getting what u hav described... pls give in detail... pls pls pls.... and can u tell me how many api keys can be generated in a single account. Numeric value?? and how many data centers are there.. pls give the correct figures if u a damm expert about mail chimp...??

jesse

unread,
Nov 1, 2012, 9:05:19 AM11/1/12
to mailchimp-...@googlegroups.com
You can generate as many API Keys as you'd like, but doing that generally doesn't make much sense aside from assigning & labeling them for use with separate integrations. If you think you need a bunch for a single application, you're likely mistaken.

The number of data centers doesn't matter - it will change. So long as you follow the instructions for constructing API Endpoints from API Keys that I linked (which are plenty detailed), you'll never have an issue with that.


jesse

Misha Developer

unread,
Nov 1, 2012, 9:22:48 AM11/1/12
to mailchimp-...@googlegroups.com
Hey thats not my answer dear.. but no prob.. your answer accepted. let me tell you that from my experience.. the datacenter mappings are really really required for a particular api to work...thats y i asked how many datacenters are there.. for example us1 to us6 or there are more or so..... in short if the the api key end with us6 then its always using the datacenter us6.. if its us1 then dc is us1...  i found the solution. so thank dear for your kind reply. but need more expertise... pls dont say that these datacenters will increase or change in future or so... if it is so then, this might create a lot of bugs like invalid api key for many mail chimp developers. in the world. as such i hv found the solution for it and now . if u want it i can give to you.. but its in c#. setting the datacenters perfectly. and will be helpful to all... hope so u understand us..

jesse

unread,
Nov 1, 2012, 9:30:33 AM11/1/12
to mailchimp-...@googlegroups.com
Nothing special or tricky here - the language used doesn't matter at all (so long as you can do basic string operations), accounts don't change data centers, and we won't change the mapping scheme, so just follow the directions for creating the endpoints. Locking this thread now...


jesse
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages