CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API to create new Mailing
Pages: [1]

Author Topic: API to create new Mailing  (Read 282 times)

Joris

  • I’m new here
  • *
  • Posts: 9
  • Karma: 1
API to create new Mailing
March 05, 2015, 09:32:06 am
Hi All,

I'm trying to create a new mailing using the api (crm v4.5.6). I'm having trouble assigning groups to include / exclude for the particular mailing.

My json string is

Code: [Select]
json={"domain_id":"1",
"name":"Test 1234",
"from_name":"Test",
"from_email":"Test@Test.be",
"replyto_email":"Test@Test.be",
"subject":"Test mailing vanuit code",
"created_id":"4",
"body_html":"Mailing <b>vanuit</b> code !!!",
"body_text":"Mailing vanuit code !!",
"url_tracking":"1",
"forward_replies":"0",
"auto_responder":"0",
"open_tracking":"1",
"override_verp":"0",
"is_archived":"0",
"dedupe_email":"0",
"groups":{"include":[1],"exclude":[2]}}

Strange thing is that the result of posting this json adds the 2 groups to the "excluded" groups inside civi.

For the life of me I can't figure out how to "include" groups. I've searched high and low but nothing relevant came up (besides a post that said to use the group variable which is a 2 dimensional array, the api interface doesn't list this variable).

Any idea's ?

Kind regards
Joris

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: API to create new Mailing
March 05, 2015, 09:36:54 am
The mailing api got some love in 4.6, and when I look in my browser console while using the new 4.6 mailing UI I see a json string like:
Code: [Select]
json:{"id":"6","domain_id":"1","header_id":"1","footer_id":"2","reply_id":"8","unsubscribe_id":"5","resubscribe_id":"6","optout_id":"7","from_name":"Demonstrators Anonymous","from_email":"info@example.org","replyto_email":"info@example.org","url_tracking":"1","forward_replies":"0","auto_responder":"0","open_tracking":"1","override_verp":"1","created_id":"203","created_date":"2015-03-05 12:24:48","is_archived":"0","visibility":"Public Pages","dedupe_email":"1","hash":"213e3ee975a92d2f","email_selection_method":"automatic","is_error":0,"name":"This is a mailing","subject":"This is only a test","body_html":"<p>Yo ho ho!</p>\n\n<p>And a bottle of rum?</p>\n","groups":{"include":[2,4],"exclude":[],"base":[]},"mailings":{"include":[],"exclude":[]}}So your code appears to be correct but not sure if it will work in 4.5 or if you need the fixes that went into 4.6.
Try asking your question on the new CiviCRM help site.

Joris

  • I’m new here
  • *
  • Posts: 9
  • Karma: 1
Re: API to create new Mailing
March 06, 2015, 01:19:58 am
Thanks for the reply,

Apparently this is also fixed in 4.5.8 :-)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API to create new Mailing

This forum was archived on 2017-11-26.