Closed dimmg closed 8 years ago
create() POSTs data. The error from the API is saying you need to use PUT, which is update() in gibbon. You might want to try upsert() instead though. I think that will cover both cases.
Thanks, Amro
Sent from my iPhone
On Apr 20, 2016, at 5:50 AM, Dima Gîra notifications@github.com wrote:
Hi, I don't know if this is gem/api related question or implementation, but after deleting a member from a list, I can't add him again. I'm obtaining that
is already a list member. Use PUT to insert or update list members. I am using the following methods to add/remove members from a list: def subscribe(email, list_id) gb = Gibbon::Request.new begin gb.lists(list_id).members.create(body: {email_address: email, status: 'subscribed'}) rescue Gibbon::MailChimpError => e puts e.message end end def unsubscribe(email, list_id) gb = Gibbon::Request.new hashed_email = Digest::MD5.hexdigest(email.downcase) begin gb.lists(list_id).members(hashed_email).delete() rescue Gibbon::MailChimpError => e puts e.message end — You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub
Using upsert
and update
instead of create
and delete
did the trick!
But it's kinda strange because delete
would mean that member has been deleted and his email is no longer in the list, and you should be able to POST him again.
Thank you!
IIRC when you unsubscribe someone, you're just changing their state, not removing them from the list. So the API is enforcing that strictly instead of being fuzzy and just doing what you expect. Basically, MC is forcing you to be explicit in your intent, which is a good thing. Conveniently, they thought of this case. :)
Thanks, Amro
Sent from my iPhone
On Apr 20, 2016, at 6:42 AM, Dima Gîra notifications@github.com wrote:
Closed #193.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub
Hi, I don't know if this is gem/api related question or implementation, but after deleting a member from a list, I can't add him again. I'm obtaining that
<specified_email> is already a list member. Use PUT to insert or update list members.
I am using the following methods to add/remove members from a list: