Replace Email body w/ {id}/fullContent.json POST endpoint | Community
Skip to main content
ggerla
New Participant
March 4, 2021
Solved

Replace Email body w/ {id}/fullContent.json POST endpoint

  • March 4, 2021
  • 1 reply
  • 3809 views

Hello there,

I'm struggling to try to update an email body with the POST {id}/fullContent.json endpoint.

 

I'm using what is written here: https://developers.marketo.com/rest-api/assets/emails/#replace_html and https://developers.marketo.com/rest-api/endpoint-reference/asset-endpoint-reference/#!/Emails/createEmailFullContentUsingPOST; but there is a little misleading process: what I have to use? A classic text/html boundary text in the POST body, or a JSON encoded parameter? I've tried many different possibilities (like the following example, or the JSON parameter, and so on), but every time, the endpoint returns "content cannot be null" error.

 

Where I'm doing wrong?

 

For example, I've something like that, where XXX is my mail ID - I will avoid all the other parameters:

CURLOPT_URL => 'https://063-XUP-724.mktorest.com/rest/asset/v1/email/XXX/fullContent.json',
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => array(
'Content-Type: multipart/form-data; boundary=----Boundaryda7e32be5795ea0',
'Content-length: 498',
'Authorization: bearer YYYY'
),
CURLOPT_POSTFIELDS => "----Boundaryda7e32be5795ea0 Content-Disposition: form-data; name="content"; filename="email_content.html"
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <div style="font: 14px tahoma; width: 100%" class="mktEditable" id="edit_text_3">Hello there!</div> </body> </html>
----Boundaryda7e32be5795ea0--"
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Looks like you still have extra whitespace (namely at the end of the boundary line).

 

The payload should look like this:

----Boundaryda7e32be5795ea0 Content-Disposition: form-data; name="content"; filename="email_content.html" Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <div style="font: 14px tahoma; width: 100%" class="mktEditable" id="edit_text_3">Hello there!</div></body></html> ----Boundaryda7e32be5795ea0--

 

Note per the MIME RFC, you should be allowed to have extraneous whitespace after the boundary:

 

 

But Marketo's MIME parser is (lightly) broken, considering any extra whitespace to be part of the boundary itself instead of ignoring it.

1 reply

SanfordWhiteman
New Participant
March 5, 2021

A classic text/html boundary text in the POST body, or a JSON encoded parameter?

It's a multipart/form-data POST with a single text/html part.

 

In your example, there's no line break between the boundary sequence and the Content-Disposition. The Content-Disposition header should be on its own line.

ggerla
ggerlaAuthor
New Participant
March 5, 2021

Sorry, my fault with the copy-paste operation.

 

CURLOPT_URL => 'https://063-XUP-724.mktorest.com/rest/asset/v1/email/XXX/fullContent.json',
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => array(
'Content-Type: multipart/form-data; boundary=----Boundaryda7e32be5795ea0',
'Content-length: 498',
'Authorization: bearer YYYY'
),
CURLOPT_POSTFIELDS => "----Boundaryda7e32be5795ea0
Content-Disposition: form-data; name="content"; filename="email_content.html"
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <div style="font: 14px tahoma; width: 100%" class="mktEditable" id="edit_text_3">Hello there!</div> </body> </html>
----Boundaryda7e32be5795ea0--"
SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 7, 2021

Looks like you still have extra whitespace (namely at the end of the boundary line).

 

The payload should look like this:

----Boundaryda7e32be5795ea0 Content-Disposition: form-data; name="content"; filename="email_content.html" Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <div style="font: 14px tahoma; width: 100%" class="mktEditable" id="edit_text_3">Hello there!</div></body></html> ----Boundaryda7e32be5795ea0--

 

Note per the MIME RFC, you should be allowed to have extraneous whitespace after the boundary:

 

 

But Marketo's MIME parser is (lightly) broken, considering any extra whitespace to be part of the boundary itself instead of ignoring it.