Update Email Content API

API_Dev
Level 2

Update Email Content API

So I see in the http://developers.marketo.com/rest-api/assets/emails/#update_editable_section part where it is mentioned that the data is passed as x-www-form-urlencoded and not JSON. I tried to pass HTTP headers as:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));


but I'm always getting the following error:

"success":false,"errors":[{"code":"611","message":"Content Type specified is not valid for the component"}

Anyone else got this same error while using this API endpoint? I've tried to add 'accept' in the header as well with value 'application/json', but I still get the same error. Any suggestions would help. Thanks

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Update Email Content API

No problem here.

I imagine you're putting something wrong on the wire.

Note providing PHP/php_curl code isn't narrowing down the problem enough. We don't all use your programming language, but many of us know what needs to be sent to the API at the HTTP level. So you should use Postman or cURL (command line) or another language-agnostic tool to build up to using your language.

API_Dev
Level 2

Re: Update Email Content API

Now, here's the weird thing. The email I'm trying to update via API is in a program that is cloned from another program (also via API), and I get this error. If I take any other email in a program manually cloned from the other program or any email with editable sections, I get success as 'true', and no error. It is just weird why I get error with API cloned emails and not with any other email (they are also of same template).

SanfordWhiteman
Level 10 - Community Moderator

Re: Update Email Content API

There's occasional weirdness with API-cloned assets that require them to be (interactively) unapproved, then reapproved.  Try that and see.  I know some of these bugs have been cleared up but some remain. In any case I don't think this is really a Content-Type issue.

API_Dev
Level 2

Re: Update Email Content API

Hi Sanford,

Thanks for your reply. So, I've found the solution and it's working fine, except when special HTML characters and latin characters are involved. The same function that does all the html encoding and string replacement, easily stores the content in the tokens (rich text), but it won't update full content in emails directly via update content API call. The content breaks whenever a special character appears.

For example, in the token the content: Cédric Dananché is stored completely. But via the UpdateEmail Content API, the content breaks at C. The special character and the remaining content after it won't update in the editable section of the email.

Do I need to try something else here or is this a marketo API issue?

SanfordWhiteman
Level 10 - Community Moderator

Re: Update Email Content API

Make sure to use UTF-8:

Content-Type: application/x-www-form-urlencoded; charset=utf-8

pastedImage_0.png

tariq_grazitti
Level 1

Re: Update Email Content API

Hi  Sanford Whiteman,
I am facing issues with the update API when I call API the form. width in request payload API gives an error as in screenshot but if I call API without width I update the image in email but the size changed in email on Marketo not as per the template size. can you please suggest?

 

 

 image.pngimage.png

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Update Email Content API

Well, this would happen if the image dimensions are locked in the email template. By default the editable image module in the email template is locked for image dimension (height and width) updates. This default behavior can be overriden by including the mktoLockImgSize="false" attribute to unlock the image's height and width properties for modification via the image editor within email or via the email content edit API.