cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to update an existing email after it was changed.

Former Member
0 Likes
933

Hello experts,

I create a message using endpoint

/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/Messages

and this payload

payload = {
    MessageName: title,
    MessageType: "EM",
    MarketingArea: marketing_area,
    DefaultLanguage: default_language,
    MessageContents: {
        results: [
            {
                LanguageCode: default_language,
                MessageContentHTMLString: html_content
            }
        ]
    }
}

And it will be created perfectly and everything seems to work.

Then I can update it using this endpoint

/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/MessageContents

and this payload

payload = {
    MessageUUID: messageUUID,
    LanguageCode: default_language,
    MessageContentHTMLString: html_content
}

And it will be updated perfectly and everything seems to work.

But if I change the settings of this email in SAP Content Studio, choose sender profile for example.

And I will try to update email using same endpoint and same payload I will receive error message "Message content can only be created for new messages."

Export failed. {"error":{"code":"CL_API_MKT_CPG_MSG/010","message":{"lang":"en","value":"Message content can only be created for new messages."},"innererror":{"application":{"component_id":"CEC-MKT-API","service_namespace":"/SAP/","service_id":"API_MKT_CAMPAIGN_MESSAGE_SRV","service_version":"0001"},"transactionid":"E5F97D06BC130570E005E470836D2FA8","timestamp":"20200218142950.2147240","Error_Resolution":{"SAP_Transaction":"For backend administrators: use ADT feed reader \"SAP Gateway Error Log\" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"},"errordetails":[{"code":"CL_API_MKT_CPG_MSG/010","message":"Message content can only be created for new messages.","propertyref":"","severity":"error","transition":false,"target":""}]}}}

How can I update message content after its settings was changed in SAP Content Studio ?

Thanks!

Accepted Solutions (0)

Answers (3)

Answers (3)

andre_axtmann
Associate
Associate

Hi Sergei,

You can indeed update with:

 PATCH 
.../MessageContents(MessageUUID={MessageUUID},LanguageCode='{LanguageCode}')

{
"MessageContentHTMLString": "<!DOCTYPE html><html><head><meta charset=\"UTF-8\">...<style type="text/css">...</head></html>"
}

But: You can only do so until another language has been added to the content.
AND: All the other content data like Subject and Blocks etc. are lost after this action.

This also applies to your similar question at https://answers.sap.com/questions/12991352/how-to-update-block-header-in-an-existing-email.html.

Best regards, André Axtmann
(SAP Marketing Cloud Development)

Former Member
0 Likes

SAP has patch endpoint (i haven't seen it in documentation) And you can update existing email after it was changed in Content Studio.

former_member226
Employee
Employee
0 Likes

Hi,

As mentioned here currently API_MKT_CAMPAIGN_MESSAGE_SRV/MessageContents only supports GET and POST i.e. either you can get the content or create the content.

In order to update the existing email template using API , you should use PUT method with endpoint API_MKT_CAMPAIGN_MESSAGE_SRV/BlockContents provided you also have the block UUID.(make a GET call forst to read the BlockContent UUID)

Thanks

Saurabh

Former Member
0 Likes

Hi! Thank you!

But i found out that in SAP Content Studio, part of the content will be moved in HTML Header (block: Header) and i don't know how to reach it. I see 4 blocks in Content Studio and only three blocks through the API if I get message blocks using this endpoint https://my302568.s4hana.ondemand.com:443/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/MessageConte... But how to reach/update header block?

Back to your answer. Imagine that i have whole email and i want to create it in SAP Content Studio through the API:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" bgcolor="#efefef" style="margin:0 !important; padding:0 !important; width: 100% !important;"><div data-sap-hpa-ceimo-block-type="SUBJECT">~TAXIDUMMYSUBJECTLINE~</div>
<div style="background:#efefef">
    <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">
    </table>
</div>
</body>
</html>

As I understand you suggest that i need to create 3 blocks: one for HTML head, one for subject line and one for body using this endpoint /sap/opu/odata/SAP/API_MKT_CAMPAIGN_MESSAGE_SRV/Blocks and put everything from ?

Than I need to create content to these three blocks using this endpoint /sap/opu/odata/SAP/API_MKT_CAMPAIGN_MESSAGE_SRV/BlockContents ?

former_member226
Employee
Employee
0 Likes

Hi,

No, you don't need to create 3 different blocks while posting the Html template/string. Maybe I was not completely clear in my last comment so here the detailed explanation, assuming you already have created a email template using API or UI and you just want o update:

1. Make GET call and get the UUID of the email

https://my301XXX-api.s4hana.ondemand.com/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/Messages?$to... eq 394 -> GET UUID

2. Make another GET call to retrieve message content in blocks

https://my301XXX-api.s4hana.ondemand.com/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/MessageContents(MessageUUID=guid'00163e38-c29e-1ee9-86e4-e93a112141a1',LanguageCode='EN')/MessageBlocks --> Find the block you want to update and get the Block UUID

3. Make another GET call to find the Message Block Content and its UUID:

https://my301XXX-api.s4hana.ondemand.com/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/Blocks(guid'00163e38-c29e-1ee9-86e4-e93a112161a1')/MessageBlockContents

4. Finally, Make a PATCH call to update the content

https://my301XXX-api.s4hana.ondemand.com/sap/opu/odata/sap/API_MKT_CAMPAIGN_MESSAGE_SRV/BlockContents(guid'00163e38-c29e-1ee9-86e4-e93a1121a1a1')

{
	"BlockContentUUID": "00163e38-c29e-1ee9-86e4-e93a1121a1a1",
        "BlockUUID": "00163e38-c29e-1ee9-86e4-e93a112161a1",
        "MessageUUID": "00163e38-c29e-1ee9-86e4-e93a112141a1",
        "BlockContentHTMLString": "Updated Content for message block"
}

BR
Saurabh

Former Member
0 Likes

Thank you. This was useful, but it doesn't solve my problem.

1. First request is working fine. I can get the UUID of the email MessageUUID=guid'fa163e35-917e-1eda-94cb-505d685398b4'

2. Second request returns 3 blocks BODY, SUBJECT, TEXT , but in SAP Content Studio there is another block "Header" and I want to update it.

How can I find and update block "Header"?

Thank you!