Mailchimp API does not replace mc: edit content sections (using ruby ​​library)

I am having a problem replacing the mc:edit content areas in Mailchimp with the content that I am providing.

E-mail is sent to subscribers, but not one of the materials provided is added to the letter. Can anyone see where I could be wrong?

This is the script I'm using:

 campaign = mailchimp.campaigns.create( "regular", { "list_id" => list_id, "subject" => "Email Test", "from_email" => "edward@somewhere.com", "from_name" => "Edward", "to_name" => "The to name", "template_id" => 35089 }, { "sections" => { "commit_stuff" => "Modified project to use XYZ ruby gem. #ABC-123", "content" => "This is the content", "more-content" => "This is more content" } } ) result = mailchimp.campaigns.send(campaign["id"]) 

And this is the section inside the letter I'm trying to change:

 <div mc:edit="commit_stuff" class="mcnTextContent">Use your own custom HTML</div> <div mc:edit="content"></div> <div mc:edit="more-content"></div> 

Relevant documents:

+10
ruby mailchimp
source share
5 answers

I struggled with this for several days using the template manager in MailChimp. The only way I worked was to export an existing template, add the mc: edit tag to the code, and then load it as a custom template.

Exporting a Template from MailChimp

  • Go to the Templates section
  • Click the "Edit" arrow next to the template you want to use with the API
  • Select "Export HTML"

Upload a template to MailChimp

  • Go to the Templates section
  • Click the "Create Template" button in the upper right corner.
  • Click "Code Your Own"
  • Then select "Import html"

Example code of my template:

 <div mc:edit="eventmessage"> Custom Event Message (replaced by API Call) <br></div> 

As a check, I could now see that the section now appears when using the / templates / info call

Once I confirmed that Mailchimp saw the template section, I used the / campaigns / create call, as mentioned above, but skipped the html definition.

Updated campaign / creation (content / sections):

  }, "content": { "sections": { "eventmessage": "Event Message Content" }, }, 
+13
source share
+1
source share

As @kateray commented above, after an hour of trying, I managed to insert my own HTML code from my backend as the content of the MailChimp campaign through API 3.0. For such a simple use case, it’s rather unpleasant not to have a ready-made solution in your documents. Of course, the MailChimp API lacks a cookbook.

So, from the very beginning:

  1. a) create a mailing list using the API or using the MailChimp web interface - create a list and b) add recipients to it - add participants .

  2. Create a new campaign through the API , create a campaign or on its website. Do not assign patterns to it .

  3. Assign a mailing list to a mailing list .

  4. Now set the campaign content using this API endpoint . Set the body of the JSON request that you send to the endpoint:

  "html": "<p>This is your custom HTML assigned to your campaign as content.</p>" } 

and send a request.

  1. In response to this request, you will receive the HTML code you specified and its text version.

  2. Go to the MailChimp web interface and make sure that all the checkboxes in the campaign are green.

  3. Submit your campaign using this API request .

NB.

+1
source share

Should there be a “content” block inside? In the API example, I see the following:

  }, "content": { "html": "example html", "sections": { "...": "..." }, "text": "example text", "url": "example url", "archive": "example archive", "archive_type": "example archive_type" }, 
0
source share

The following php code worked for me

 $api = new MCAPI($apikey); $type = 'regular'; $opts['list_id'] = 'id'; $opts['subject'] = 'The subject'; /*<div mc:edit="std_content00">*/ $content = array('html_std_content00'=> $template); $retval = $api->campaignCreate($type, $opts, $content); 
-6
source share

All Articles