0

I am trying to subscribe a user to a mailing list through the REST API. I understand that I need to create a Contact first, then subscribe it to a given mailing list. While I can create the contact, I can't subscribe it to the list using parameters:

entity: 'MailingEventSubscribe' action: 'create' email: [the-contact-email-here] group_id: [the-mailing-list-group-id-here]

This will result in {"is_error":1,"error_message":"Subscription failed"}

The CiviVRM version here is 4.2.0 I could't find documentation for the API on this specific version, so I'm playing the guessing game here :). I've been also told that the API requests can be chained somehow in order to do just 1 instead of 2, is there a documentation for this?

Can someone point me into the right direction? Thanks.

1
  • A lot has happened in the Civi world since 4.2.0. I'd strongly recommend upgrading.
    – Aidan
    Jul 9, 2018 at 8:40

1 Answer 1

0

The mailing list is actually a group in CiviCRM. The functionality of a group is bit more than just mailing list, but fine if you only want to use it for that.

It means that all you have to do is add the contact to the relevant group using the GroupContact API AFAIK.

2
  • So if I understand it correct 'MailingEventSubscribe' is not the right entity, maybe 'Group' or even 'GroupContact' is the right one then.
    – zlat
    Jul 4, 2018 at 10:53
  • GroupContact is the right one, that adds a contact to a group. There is an example here: pastebin.com/StqnyrdY Jul 4, 2018 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.