I’m using an App Extension for Constant Contact to create an email campaign from a Drupal website but I’m having trouble importing HTML for the email because the special characters (like < and >) are being encoded (to < and >) which results in invalid JSON.
TL;DR : Is it possible to use an input field in App Extensions that supports HTML? Currently I can only use Text or String for this field, which I believe is incorrectly encoding my HTML and is resulting in these issues.
------
I have already added transforms to escape characters that would result in JSON errors, but when HTML is placed in the Body of the App Extension, it is being processed as a string and encoded like this:
Original value: <p><a href=\"\">Visit ConstantContact.com!</a>
Encoded value: <p><a href=\"https://constantcontact.com/\">Visit ConstantContact.com!</a></p>
These encoded characters are resulting in the error: “Request body contains invalid JSON.” When I test the request via the Constant Contact API manually with the Original value in place, it succeeds. Note: I am using valid to and from emails, just not posting them here. I also am submitting each request with a unique “name” value since that is also a requirement. See below:
Successful Request through Constant Contact API test:
https://developer.constantcontact.com/api_reference/index.html#!/Email_Campaigns/createEmailCampaignUsingPOST
{
"name": "Email Campaign Subject 1",
"email_campaign_activities": p
{
"format_type": 5,
"from_name": "XXX",
"from_email": "test@test.org",
"reply_to_email": "test@test.org",
"subject": "Email Campaign Subject",
"preheader": "Preheader",
"html_content": "<html><body> "trackingImage]]<p><a href=\"\">Visit ConstantContact.com!</a></p></body></html>”
}
]
}
Failed Request though Zapier test:
{
"name": "Email Campaign Subject 2",
"email_campaign_activities":
{
"format_type": 5,
"from_name": "XXX",
"from_email": "test@test.org",
"reply_to_email": "test@test.org",
"subject": "Email Campaign Subject",
"preheader": "Preheader",
"html_content": "<html><body>ertrackingImage]]<p><a href=\"https://constantcontact.com/\">Visit ConstantContact.com!</a></p></body></html>”
}
]
}