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?
Solved! Go to Solution.
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!
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!
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!
API Support Engineer