Re: POST-ing content to email templates

Anonymous
Not applicable

POST-ing content to email templates

The REST API documentation for the creating email templates says that the html content should be a multipart file, but the endpoint and example body suggests that the request should be application/json. Is this a mistake in the documentation? Can the HTML content just be sent as a string? Or can the request be made url encoded instead? 
Tags (1)
3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: POST-ing content to email templates

I don't think there's necessarily a mismatch there because `content` is a string value within a JSON request payload, not the entire payload  The word "file" however is misleading.  Based on the docs for getting email content, they mean a JSON-safe string representation of the multipart content.
Anonymous
Not applicable

Re: POST-ing content to email templates

This endpoint is giving me system errors. Here's a curl example:


curl -v -X POST -H 'User-Agent: Faraday v0.9.1' -H 'Content-Type: application/json' -d '{"content":"\u003c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eBogus Email\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv style=\"font: 14px tahoma; width: 100%\" class=\"mktEditable\" id=\"edit_text\"\u003e\n      Greetings {{lead.Full Name:default=Muggle}},\n    \u003c/div\u003e\n\n    \u003cdiv style=\"font: 14px tahoma; width: 100%\" class=\"mktEditable\" id=\"edit_text\"\u003e\n      Youve been selected.\n    \u003c/div\u003e\n\n    \u003cdiv style=\"font: 14px tahoma; width: 100%\" class=\"mktEditable\" id=\"edit_text\"\u003e\n      Regards,\u003cbr/\u003e\n      Me\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e"}ve been selected.\n    \u003c/div\u003e\n\n    \u003cdiv style=\"font: 14px tahoma; width: 100%\" class=\"mktEditable\" id=\"edit_text\"\u003e\n      Regards,\u003cbr/\u003e\n      Me\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e"}' "https://851-VXS-635.mktorest.com/rest/asset/v1/emailTemplate/1075/content.json?access_token=<pretend this is a valid token>"

SanfordWhiteman
Level 10 - Community Moderator

Re: POST-ing content to email templates

I'll have to look at this later, as I don't have time this week.  I will say that you don't need to hide < and > in JSON (by using \unnnn). You can, yes, but you can also use actual Unicode characters, which is quite a bit easier to read!