Update dynamic image content by API | Community
Skip to main content
New Participant
April 8, 2022
Question

Update dynamic image content by API

  • April 8, 2022
  • 1 reply
  • 4141 views
Hi, I have a few questions regarding modification dynamic image content in emails by Rest API. Generally I need update alternative text, but to update just this property, it is neccessary provide request with all content arguments (image url, alt text, with, style...). See issues bellow.

 

1. Sometimes it is not possible to update image due to Invalid URL error. See for example image content bellow (dynamic image content):
GET /rest/asset/v1/email/1717/dynamicContent/RVMtc2luZ2xl.json
Response:
[ { "createdAt": "2022-04-06T14:47:45Z+0000", "updatedAt": "2022-04-06T14:47:45Z+0000", "id": 1717, "segmentation": 1011, "content": [ { "id": "MTMzMg**", "segmentId": 1041, "segmentName": "Default", "content": "https://via.placeholder.com/1200x400", "type": "Image", "width": "600", "altText": "MULTIPLE.PNG", "linkUrl": "https://via.placeholder.com/1200x400", "style": "-ms-interpolation-mode: bicubic; outline: none; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; text-decoration: none; border-top-width: 0; display: block; max-width: 100%; line-height: 100%; height: auto; width: 600px" }, ... ] } ]
 
And if I try to update segment by API with the same url that was configured in UI, it fails. This happens only for some URLs. See request and response bellow.
POST /rest/asset/v1/email/1717/dynamicContent/RVMtc2luZ2xl.json Body: segment=Default&type=Image&externalUrl=https://via.placeholder.com/1200x400&altText=updated-alt-text
Response:
{ "success": false, "errors": [ { "message": "Invalid URL", "code": "701" } ], "requestId": "11ea3#18008f813ba", "warnings": [] }
 
Are there any restrictions in url validation? Why modification in UI works but it fails for API call?

 

 

2. Is it possible somehow update segmented image content of File type (image uploaded from my computer)?
See dynamic image content bellow:
GET /rest/asset/v1/email/1717/dynamicContent/RVMtYXJ0aWNsZTQ=.json [ { "createdAt": "2022-04-08T11:53:10Z+0000", "updatedAt": "2022-04-08T11:53:10Z+0000", "id": 1717, "segmentation": 1011, "content": [ { "id": "MTM0NQ**", "segmentId": 1041, "segmentName": "Default", "content": "5396", "type": "File", "contentUrl": "http://063-RVK-838.mktoweb.com/rs/063-RVK-838/images/marketo-image-from-computer.png", "height": "auto", "width": "270", "altText": "marketo-image-from-computer.png", "style": "" } ] } ]
I tried the following API request, but it fails with `Invalid data for Type.` message.
POST /rest/asset/v1/email/1717/dynamicContent/RVMtc2luZ2xl.json Body: segment=Default&type=File&contentUrl=http://063-RVK-838.mktoweb.com/rs/063-RVK-838/images/marketo-image-from-computer.png&altText=updated-alt-text
Response:
{ "success": false, "errors": [ { "message": "Invalid data for Type.", "code": "701" } ], "requestId": "4724#1800912a367", "warnings": [] }

 

 

3. Is it possible detect by API call that segmented image has locked size? The issue is that I want to change dynamic image content but I don't know whether image size is locked or not, so if size is locked and image width is provided in update request it fails with `Error processing Image: Image size is locked in email template. Cannot edit image size`. This error occurs even if file size is not changed.
GET /rest/asset/v1/email/1717/dynamicContent/RVMtc2luZ2xl.json
Response:
[ { "createdAt": "2022-04-06T14:47:45Z+0000", "updatedAt": "2022-04-06T14:47:45Z+0000", "id": 1717, "segmentation": 1011, "content": [ { "id": "MTMzMg**", "segmentId": 1041, "segmentName": "Default", "content": "https://via.placeholder.com/1200x400", "type": "Image", "width": "600", "altText": "MULTIPLE.PNG", "linkUrl": "https://via.placeholder.com/1200x400", "style": "-ms-interpolation-mode: bicubic; outline: none; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; text-decoration: none; border-top-width: 0; display: block; max-width: 100%; line-height: 100%; height: auto; width: 600px" }, ... ] } ]
And modification request:
POST /rest/asset/v1/email/1717/dynamicContent/RVMtc2luZ2xl.json Body: segment=Default&type=Image&externalUrl=https://placekitten.com/200/300&a&altText=updated-alt-text&width=600
Response:
{ "requestId": "4a3e#18009178a1c", "success": false, "warnings": [], "errors": [ { "code": "611", "message": "Error processing Image: Image size is locked in email template. Cannot edit image size" } ] }
 
 
Thanks a lot
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Darshil_Shah1
Community Manager
April 8, 2022

1. This is a known issue, and probably the difference b/w the images that load and doesn't load is the presence of CORS header in the once that do load - there's an old thread linked here FYR.

2. Can you try hitting the endpoint with the type = Image and value = <image asset-Id-in-DS> parameters along with the segment  parameter? Guess this should do the trick!

3. The getcontent endpoint does return the isLocked Boolean attribute, but I'm not 100% sure if isLocked attribute's value for the image modules do mean the image dimensions are adjustable and un-locked at the template level.

New Participant
April 14, 2022

Thank you for response.

 

2. I tried your solution and it did the trick. Thank you

3. I checked  isLocked attribute in getcontent endpoint and the value seems to be independent of lock image size value. So there is probably no way how to get lock image size attribute value, except reading plain email template and parse the value from html.

 

Actually in our scenario we just need update altText of Image, but to modify it, it's necessary provide all other attributes in update request (POST /rest/asset/v1/email/{emailId}/dynamicContent/{dynamicContentId}.json). It is strange that it is not possible to use same values that were returned by read endpoint  (GET /rest/asset/v1/email/{emailId}/dynamicContent/{dynamicContentId}.json). This makes all quite challenging. Do you think there is a chance this could be addressed sometimes in the future?

 

Thanks

Darshil_Shah1
Community Manager
April 14, 2022

 

3. I checked  isLocked attribute in getcontent endpoint and the value seems to be independent of lock image size value. So there is probably no way how to get lock image size attribute value, except reading plain email template and parse the value from html.

 


That's what I inferred from my testing, 👍 I tried looking up in the documentation but couldn't find much!

 

Well, segment, type, and value are the mandatory attributes for the POST request - you can store these values locally and use it in-case if you just want to update the alt-text, I think that shouldn't cause any issues.