Hello!
I am currently doing some integrations for my company using the Marketo's REST API and recently I've encountered some strange behaviour related to program cloning via the specific REST API endpoint. I will explain the steps that eventually ended up in seeing this behaviour and resulting in a 611 error.
1) The program that I am working with is circled with black, as depicted below. It is a simple program having only one email in it.
To clone this program, I've used the specific endpoint as presented in the official documentation:
"https://{HostUrl}/rest/asset/v1/program/{id}/clone.json", where id represents the id of the program that I want to clone (i.e. the id of the "TestingProgram" program). For this request, I have used the following body:
{
"folder": {
"id": 407,
"type": "Folder"
},
"name": "TestingProgram-clone"
}
where "folder" represents the folder that I want the program to be cloned in (i.e "GeorgeTest" folder). Of course, using this endpoint worked as expected, and the program was successfully cloned, as you can see below.
2) At this step, I've realised that something went wrong, though. Calling the endpoint "Get Email Content"(https://{HostUrl}/rest/asset/v1/email/{id}/content.json?status=approved) on both of the "ComplexEmail" emails (i.e. the one from the original program and the one from the cloned program) resulted in 2 different outcomes, as the email from the
cloned program had 68 sections compared to the original email, which had only 40 sections.
3) I have furhter investigated and tried to iterate over those sections of the email from the cloned program that were of type "Text" and execute the "Update Email Content Section" endpoint (https://{HostUrl}/rest/asset/v1/email/{id}/content/{htmlId}.json), using the following POST body:
{
"type": "Text",
"value": <Html content for this section>,
}
Unfortunately, as expected from step 2, the increased number of sections was due to duplicating some of them when executing the cloning of the program via REST API. This resulted in a 611 error when trying to call the "Update Email Content Section" endpoint on a section that has been duplicated (i.e. a section that has an "htmlId" that already exists). The error message is presented below:
{"requestId":"2e9b#172cbddd3c2","success":false,"warnings":[],"errors":[{"code":"611","message":"org.hibernate.NonUniqueResultException: query did not return a unique result: 2"}]}
To add some more helpful information, I've tried cloning the program via the UI and execute step 2 to see if there was any difference. Surprisingly, there wasn't, as this time the number of emails' sections remained the same (40 vs 40). So cloning from the UI doesn't reproduce this behaviour. I've also tried cloning the email using the specific "Clone Email" endpoint and this also worked perfectly fine, no duplicate sections were added. Moreover, I've tried to take a look at the email from the cloned program, to see if I cand find those duplicated sections. Surprisingly again, they were nowhere to be seen, as in the UI the email looked exactly the same to the original email from the original program. Also, the template that the email is using is called "Flatirion" from the Marketo Starter Template bundle.
I'd be greatly thankful if someone could help me through with this problem.
Kind regards,
Rares