I built an email template via the Mailchimp drag and drop tool. I'm trying to now create a new email campaign using the template as the new campaign content but it doesn't seem to be working. I chatted with Mailchimp support several times and they also didn't know why it isn't working and had no solutions.
I get no errors. It successfully creates a new campaign but uses default content (not the desired email template I built). I use actual variables in my code for api_key, server, email address, and templateID.
Via the Mailchimp API documentation, this is my code:
import mailchimp_marketing as MailchimpMarketing
from mailchimp_marketing.api_client import ApiClientError
mailchimp = MailchimpMarketing.Client()
mailchimp.set_config({
"api_key": "api-key",
"server": "server-num"
})
try:
# Create a new campaign
campaign = mailchimp.campaigns.create({
"type": "regular",
"settings": {
"subject_line": "Test Email Subject Line",
"reply_to": "email@email.com",
"from_name": "Sender Name"
}
})
# Set campaign content
campaign_content = mailchimp.campaigns.set_content(campaign['id'], {
"template": {
"id": templateID
}
})
print('Campaign Created:', campaign['id'])
except ApiClientError as error:
print("Error: {}".format(error.text))
Mailchimp Marketing API Documentation: https://mailchimp.com/developer/marketing/guides/quick-start/