Hi,
Referring to Marketo Community post https://nation.marketo.com/t5/product-discussions/update-dynamic-image-content-by-api/m-p/323850/hig... , on extracting and updating email image alt text, I am also trying to update the email image alt text using Dynamic Content API of Marketo, however, ran into an issue of the email image alt text updation breaking the email image itself. Sharing the steps I followed below.
I am trying to run an API call to retrieve and update the Dynamic content of the Email Image alt text.
I am running 2 API calls
(1) GET : GET /rest/asset/v1/email/{id}/dynamicContent/{contentId}.json to get the content id and the type of the email module (https://developers.marketo.com/rest-api/endpoint-reference/asset-endpoint-reference/#!/Emails/getEma...). I am using the dynamic content GET call to extract: segmentation name, segmentation ID, content ID, content type, emailID, dynamic content type, dynamic content ID.
(2) POST : I am using the Dynamic Content POST to update the Dynamic email image alt text Dynamic Content after retrieving the emailID, Dynamic Content, Dynamic Content ID, segment name, segment ID.
However, when I try to update the image URL alt text using this POST API call, after adding the specific altText parameter under "$Params" for this specific dynamic section upload type, it updates the image URL alt text but it breaks the Marketo email image itself. Can you please advise a way that it should not break the email image module?
In summary,
The Alt text updates correctly for images which has spaces in their names but on the UI end the image doesnt load as the API automatically removes the spaces and tries to look for the image without spaces on Marketo which doesnt exist.
Url change that happens when we make the image API call.
the code used to extract dynamic image alt text content :
if($dynamic_content['type'] == "HTML") { fwrite($file,"\n" .$email->getId() . "\t" . $dynamic_content['seg_id'] . "\t" . $dynamic_content['seg_name'] . "\t" . $type . "\t" . $content_id . "\t" . $name . "\t" . $dynamic_content['type'] ."\t\"" . str_replace("\"","\"\"",$dynamic_content['content']) . "\""); break; } if($dynamic_content['type'] == "Image") { fwrite($file,"\n" .$email->getId() . "\t" . $dynamic_content['seg_id'] . "\t" . $dynamic_content['seg_name'] . "\t" . $type . "\t" . $content_id . "\t" . $name . "\t" . $dynamic_content['type'] ."\t\"" . str_replace("\"","\"\"",$dynamic_content['altText']) . "\""); break; }
httpPost($this->getBaseUrl() . "/email/" . $this->getId() . "/dynamicContent/" . $content_id . ".json?access_token=" . $this->access_token . "&segment=" . $segment . "&type=" . $type,$params,$header);
Any guidance you can provide is much appreciated.
Thank you
Solved! Go to Solution.
It’s easier to get help if you post actual HTTP payloads, not PHP. Otherwise you’re asking us to set up a PHP environment just to see what goes on the wire — which is the only thing that matters, regardless of language.