Update email and landing page content sections via REST API

Mihai_Dobrescu6
Level 1

Update email and landing page content sections via REST API

Hello,

I'm trying to update via REST API the content of emails and landing pages but I'm getting strange errors when I'm trying to do it.

For Email content I have this section:

{
"htmlId": "Banner2",
"value": {
"value": "https://dummyimage.com/640x240/ccc/000",
"width": "640",
"al Text": "banner"
},
"contentType": "Image",
"parentHtmlId": "Banner",
"isLocked": false
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I'm trying to update the link in this section but of course I get the response that the "type" is needed. In Marketo documentation it says that the "type" can only have 3 options: "Text", "DynamicContent" and "Snippet". 

I've tried to use the "Text" type like this:

https://xxx-OTA-xxx.mktorest.com/rest/asset/v1/email/1964/content/Banner2.json?access_token=xxx&type=Text&value={"value":"https://dummyimage.com/600x450/000/fff","width":"640","altText":"banner"}

But I'm getting this error:

"code": "611",
"message": "Content Type specified is not valid for the component"‍‍

I'm using "application/x-www-form-urlencoded" as Content type on the request.

On a Landing page I'm trying to update the link as well in this section:

{
"id": "13676",
"type": "Image",
"index": 1,
"content": {
"content": "12577",
"contentType": "File",
"contentUrl": "https://app-lon02.marketo.com/rs/275-OTA-175/images/0.png"
},
"formattingOptions": {
"height": "200px",
"width": "200px",
"zIndex": 15,
"left": "541px",
"top": "172px",
"imageOpenNewWindow": true
}
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I'm doing this request:

https://xxx-OTA-xxx.mktorest.com/rest/asset/v1/landingPage/2158/content/13676.json?access_token=xxx&type=Image&value={"id":"13676","type":"Image","index":1,"content":{"content":"12577","contentType":"File","contentUrl":"https://dummyimage.com/600x450/000/fff"},"formattingOptions":{"height":"200px","width":"200px","zIndex":15,"left":"541px","top":"172px","imageOpenNewWindow":true}}‍‍

And I'm getting this response when the LP is on draft mode:

{
"code": "709",
"message": "Operation is only allowed on draft landing page content"
}‍‍‍‍

Am I doing the request wrong? meaning the parameters are not set properly in the request?

So yes, I'm trying to update links on assets content but the lack of examples on Marketo documentation is not helping.

Could anyone with experience on updating assets via REST API could please help?

Thank you,

Mihai

2 REPLIES 2
Amit_Jain
Level 8 - Community Advisor

Re: Update email and landing page content sections via REST API

You are doing it wrong. To update the image link on the LP, you do not really have to pass a jSON object like this. Just try following:

https://xxx-OTA-xxx.mktorest.com/rest/asset/v1/landingPage/2158/content/13676.json?access_token=32a177d8-6ef3-4f94-ac76-f1999672a1dd:sn&type=Image&value=<id of the image in Marketo>

A few point:

  • The Id highlighted in green, should be the landing page id
  • The ID in the red, should be content ID. It is the HTML ID of the section. Ideally it's more descriptive like "header image" or "Logo" or something. So make sure you are using the right ID here.
  • The value parameter, in Blue above,should be the Marketo ID of the image i.e. if the image doesn't exists in Marketo, first upload that and find out the ID of the asset from the Marketo from design studio link. See example below:pastedImage_18.png

You have to do similar thing for Email as well. Try and let me know if you still face any issue.

Mihai_Dobrescu1
Level 1

Re: Update email and landing page content sections via REST API

Hi Amit,

 

It works for images that are hosted on Marketo, so thank you.

 

I was trying to use an externalURL for the image so I was trying to send in the request body:

{
"externalUrl":'https://dummyimage.com/600x450/000/fff'
}

 

I get a success message but the previous image is deleted and the new one is not added. So it acts like an image removal.

 

When i add this image from Marketo interface, it's visible in the asset. 

 

Do you have an idea how to solve this issue?

 

Thank you,

 

Mihai