Update Email Address in Mailchimp Using the Mailchimp API

I am trying to synchronize a person’s record with my database on mailchimp. I can update all fields except email. Email I can update only once. When you upgrade again, it throws an error. I use their java APIs. This is what I do -

emailType = ""; replaceInterests = false; mergeVars.put("EMAIL", rs.getString("email")); Boolean rc = mcServices.listUpdateMember(apiKey, listId, mailChimpId, mergeVars, emailType, replaceInterests); 

Re-access error message -

com.nwire.mailchimp.MailChimpServiceException: oldEmail@email.com not a member of listName on com.nwire.mailchimp.MailChimpServiceFactory $ ClientFactory $ 1.invoke (MailChimpServiceFactory.java:190) in $ Proxy0.listUpdateMember. unknown mailchimp.test.TestMCList1.updateDetails (TestMCList1.java:121) at com.nwire.mailchimp.test.TestMCList1.sync (TestMCList1.java:92) at com.nwire.mailchimp.test.TestMCList1.run (TestMCListjava 52) on com.nwire.mailchimp.test.TestMCList1.main (TestMCList1.java:35)

Please note that the oldEmail@email.com in the error message is the original email address in Mailchimp shich, which I successfully updated once, but is still displayed with repeat links.

thanks

0
source share
2 answers

I'm really not sure what you are using as mailChimpId , but it is also an email address. Therefore, when changing email, this variable must also change. In your case, it will look like this:

 String email = rs.getString("email"); mergeVars.put("EMAIL", email); Boolean rc = mcServices.listUpdateMember(apiKey, listId, email, mergeVars, emailType, replaceInterests); 

Hope this helps (I wrote this Java shell and it works fine on my server).

0
source

Along with the old email address, i.e.

mergeVars.put ("EMAIL", email);

you define new as follows:

mergeVars.put ("NEW-EMAIL", new-email address);

Thus, you need both old and new addresses in orer for updating.

0
source

Source: https://habr.com/ru/post/1488257/


All Articles