Branden Williams
Branden Williams

Reputation: 93

Gibbon API does not error, but does not subscribe

This is a strange one. I've had a working MailChimp, Gibbon, RoR app going for a couple of years now, and I went to go use part of my app this week and realized that the integration was no longer working. I am not receiving any errors, and some basic testing shows that the exception section of the code is never called.

Here is the code I am using:

begin
  gb = Gibbon::API.new(mailchimp_api_key)
  gb.lists.subscribe( id: mailchimp_list_id, email: {email: email} )
rescue Gibbon::MailChimpError => e
  logger.error "Mailchimp threw an error. The code is: #{e.code}, with message: #{e.message}"
end

Some code edited for readability, but assume that the variables are defined and no errors are thrown.

What I'm looking for is some debugging help. I can't seem to find a way to debug the integration to know if there is something silently failing or not. Does anyone have any tips for debugging this outside of trying to catch a raised exception?

Upvotes: 0

Views: 683

Answers (2)

Branden Williams
Branden Williams

Reputation: 93

Thanks!

And yep, I do get a response back that matches what you suggested (note, I used a real email address):

{
  "email"=>"[email protected]", 
  "euid"=>"3cb513752a", 
  "leid"=>"89681797"
}

Strangely enough, it does show up on the mailchimp side as pending subscription, but the subscription confirmation is not sending. That sounds like I have a MailChimp problem, not a gibbon problem. Does anyone know of a setting on the MailChimp side I am missing?

Will keep digging...

Upvotes: 0

Kaëris
Kaëris

Reputation: 3384

I use the same code and when something wrong an exception is thrown. You should check and print what subscribeis returning.

response = gb.lists.subscribe( id: mailchimp_list_id, email: {email: email} )
puts response

According to the mailchimp documentation it should return a JSON like this one :

{
    "email": "example email",
    "euid": "example euid",
    "leid": "example leid"
}

https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php

Upvotes: 2

Related Questions