cancel
Showing results for 
Search instead for 
Did you mean: 

How to add existing template to new campaign through the API

SOLVED
Occasional Contributor

How to add existing template to new campaign through the API

I'm working with the Create New Email API.  I want to use an existing email template from my account as the email.  I attempted to use the html from the email of a previous campaign and the API failed with the error Unable to Parse JSON.  How do you point the email content of the new Campaign at an existing email template?

4 REPLIES 4
Honored Contributor

Re: How to add existing template to new campaign through the API

Hello,

 

It is unfortunately not possible at this time to create a campaign through the API while using an existing campaign as the base. However, you should be able to use any valid HTML as the contents of a campaign as long as the contents are properly escaped in the payload. Depending on what language you're working in, there should be libraries available to handle the process of escaping the HTML code to avoid JSON errors.

 

If you're able to provide any additional details, I would be happy to provide assistance!

 

Sincerely,

Elijah G.
API Support Engineer
Highlighted
Occasional Contributor

Re: How to add existing template to new campaign through the API

Hi Elijah,

 

I attempted to use the html from the existing email in constant contact.  If you look at an old campaign and inspect the email there is a link to the email html.  I used that to get the html for the email.  I then ran a html encode operation on it then pasted it in the JSON field email_content when I created the campaign.  That resulted in the error.  I also downloaded the example C# source code, EmailCampaignExample, and it also failed in that project.  I've attached the file with the html I used html encoded.  Thanks!

 

Honored Contributor

Re: How to add existing template to new campaign through the API

Hello,

 

I had a look at the HTML, and was able to put it into an email with the API. The key thing that needed to be done was to encode the HTML content for JSON. A good example of one thing that happens when you encode is that a double quote(") will become escaped: \"

 

If you're looking to do this programmatically, you will need to find a tool for your language of choice that can handle this encoding. If you just want to make the API calls directly, you can look up an online tool to do the encoding for you.

 

If you have any questions or if I can provide any guidance, please let me know!

 

Sincerely,

Elijah Gaiter

API Support Engineer

Elijah G.
API Support Engineer
Member

Re: How to add existing template to new campaign through the API

Thanks for your attention Elijah.  I did some hunting and put together some C# code to parse the HTML and I was able to create a new campaign with the same html I sent you.  Thank you very much!