Wrong Datacenter Invalid Key Error

853 views
Skip to first unread message

Max Keeler

unread,
Nov 19, 2013, 1:07:53 PM11/19/13
to mailchimp-...@googlegroups.com
Hello,

I am intermittently receiving this error:

Invalid Mailchimp API Key: ### . You are accessing the wrong datacenter - your client library may not properly support our datacenter mapping scheme.
Interestingly, when I create a new api key and configure my code to use it, it works fine, for a while, and then I get the error again.  If I switch back to the original key, it works again!  For a while, and then breaks again.
One thing to note is that the application (which is synchronizing lists) is accessing multiple accounts with different keys.  It almost seems as though a key is disabled if there is some sort of activity that flags irregular behavior or something.
I'm using the latest MailChimp python package.
Any ideas?
Thanks,
Max

Eric Muntz

unread,
Nov 19, 2013, 1:10:00 PM11/19/13
to mailchimp-api-discuss
Hey Max,

Sounds like the URL to hit the API is being cached statically or in a class instance variable that's being reused and not properly rebuilt on every access of the API with a different key.  I'd need to see all of the code to know if that's the deal or not, though.  You could try making sure you re-initialize the object you are calling for API access on all accesses for a different user / API key and see if that clears it up.


--
You received this message because you are subscribed to the Google Groups "MailChimp API Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mailchimp-api-di...@googlegroups.com.
To post to this group, send email to mailchimp-...@googlegroups.com.
Visit this group at http://groups.google.com/group/mailchimp-api-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Max Keeler

unread,
Nov 19, 2013, 4:06:04 PM11/19/13
to mailchimp-...@googlegroups.com
Eirc,

Thanks for the reply, much appricated.  I believe in all cases I'm initializing a new object inside the function, like so:

def find_last_mailchimp_sub_date(mailchimp_list_id, api_key):
    mc
= mailchimp.Mailchimp(apikey=api_key)
    members
= mc.lists.members(id=mailchimp_list_id, status='subscribed',
                               opts
={'sort_field': 'last_update_time', 'sort_dir': 'DESC'})


    date
= members['data'][0]['timestamp']
   
return date


It's definitely possible that something is getting cached though, I'll look into that more.

Max


On Tuesday, November 19, 2013 1:10:00 PM UTC-5, Eric Muntz wrote:
Hey Max,

Sounds like the URL to hit the API is being cached statically or in a class instance variable that's being reused and not properly rebuilt on every access of the API with a different key.  I'd need to see all of the code to know if that's the deal or not, though.  You could try making sure you re-initialize the object you are calling for API access on all accesses for a different user / API key and see if that clears it up.
On Tue, Nov 19, 2013 at 1:07 PM, Max Keeler <max.k...@gmail.com> wrote:
Hello,

I am intermittently receiving this error:

Invalid Mailchimp API Key: ### . You are accessing the wrong datacenter - your client library may not properly support our datacenter mapping scheme.
Interestingly, when I create a new api key and configure my code to use it, it works fine, for a while, and then I get the error again.  If I switch back to the original key, it works again!  For a while, and then breaks again.
One thing to note is that the application (which is synchronizing lists) is accessing multiple accounts with different keys.  It almost seems as though a key is disabled if there is some sort of activity that flags irregular behavior or something.
I'm using the latest MailChimp python package.
Any ideas?
Thanks,
Max

--
You received this message because you are subscribed to the Google Groups "MailChimp API Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mailchimp-api-discuss+unsub...@googlegroups.com.

Max Keeler

unread,
Nov 27, 2013, 10:31:28 AM11/27/13
to mailchimp-...@googlegroups.com
I've found the issue here, it appears that my version of the mailchimp python library (2.0.7) sets a global variable (ROOT) when creating the api post url.  This global variable seems to be set across instances.  Here's the line:

global ROOT
ROOT
= ROOT.replace('https://api.', 'https://'+dc+'.api.')

But since root is already set to https://us3.api... the replace for the new datacenter doesn't work.

Something like this should fix it:

ROOT = re.sub(r'.*api', 'https://' + dc + '.api', ROOT)

Max

Yann Kerhervé

unread,
Jan 6, 2014, 4:09:47 PM1/6/14
to mailchimp-...@googlegroups.com
I found the same thing.

It would be nice if the official client were fixed. In the meantime I rolled my own patch:


Yann
Reply all
Reply to author
Forward
0 new messages