Skip to main content

Notifications

Community site session details

Community site session details

Session Id : HQel61t9wBajktqlittSJA
Power Automate - Building Flows
Unanswered

Translating and Saving Canvas Content as Draft

Like (0) ShareShare
ReportReport
Posted on 3 Jan 2025 07:59:21 by 29

I’m using a Power Automate flow to translate the CanvasContent1 of a SharePoint page via the API call _api/web/lists/GetByTitle('Site%20Pages')/items(52)/CanvasContent1. After extracting the content, I parse it as JSON and translate it into another language using the "Translate Text" action. I can see the translation works fine

While attempting to save the translated content back as a draft, the flow often fails with a "Bad Gateway" error, and the process takes hours before timing out.

Questions:

  1. What could be causing the delay and the "Bad Gateway" error during this operation?
  2. Are there any best practices for handling large or complex CanvasContent1 to ensure it translates and saves efficiently in Power Automate?
  3. Would using a different API endpoint or method to update the page content help avoid this issue?

Any insights or recommendations to streamline this process would be greatly appreciated.

Thanks in advance for your assistance!

 

Scheme I'm using in my parse.json 

{
    "type": "object",
    "properties": {
        "type": {
            "type": "string"
        },
        "properties": {
            "type": "object",
            "properties": {
                "d": {
                    "type": "object",
                    "properties": {
                        "type": {
                            "type": "string"
                        },
                        "properties": {
                            "type": "object",
                            "properties": {
                                "CanvasContent1": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
I use the outcome of my parse.json for the translation. 
 
the outcome of the translation.
{
    "statusCode": 200,
    "headers": {
        "Cache-Control": "no-cache",
        "Vary": "Accept-Encoding",
        "Set-Cookie": "ARRAffinity=9773387b6e0d4bc7a1e310d8e03534321ec431ccd30b0d4a097e9e1a610d81ce15134d20c556b0b34b9b6ae43ec3f5dcdad61788de889ffc592af7aca85fc1c508DD2BCF76A60C291953144650; path=/; secure; HttpOnly,ReqClientId=06d2513a-e323-4a2b-be89-a194d5a82825; expires=Thu, 03-Jan-2075 07:50:20 GMT; path=/; secure; HttpOnly,ARRAffinity=9773387b6e0d4bc7a1e310d8e03534321ec431ccd30b0d4a097e9e1a610d81ce15134d20c556b0b34b9b6ae43ec3f5dcdad61788de889ffc592af7aca85fc1c508DD2BCF76A60C291953144650; path=/; secure; HttpOnly",
        "x-ms-service-request-id": "ba9c1577-9196-47cf-8b9d-f480fc7a1988",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "REQ_ID": "ba9c1577-9196-47cf-8b9d-f480fc7a1988",
        "CRM.ServiceId": "CRMAppPool",
        "AuthActivityId": "ff4bbd50-f8f6-413d-af6b-940e622f6b2b",
        "x-ms-dop-hint": "4",
        "x-ms-ratelimit-time-remaining-xrm-requests": "1,198.22",
        "x-ms-ratelimit-burst-remaining-xrm-requests": "7994",
        "mise-correlation-id": "49ad98ad-3a38-43b7-82e6-79cb009c9f6e",
        "OData-Version": "4.0",
        "X-Source": "24070241821391092020317924823935187452361649719721713412117203175166211219211101181224182,4924571311064814124416105617917515711424815097103208436220514707517273204771817",
        "Public": "OPTIONS,GET,HEAD,POST",
        "Date": "Fri, 03 Jan 2025 07:50:21 GMT",
        "Allow": "OPTIONS,GET,HEAD,POST",
        "Content-Type": "application/json; odata.metadata=minimal",
        "Content-Length": "6040",
        "Expires": "-1"
    },
    "body": {
        "@odata.context": "https://org4640923e.crm4.dynamics.com/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.PredictResponse",
        "responsev2": {
            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
            "operationStatus": "Success",
            "predictionId": "ce66a32f-f6e2-4b25-bbc0-bfe1d4a929d1",
            "predictionOutput": {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "text": "{&quot;d » :{&quot;CanvasContent1 » :&quot;<div><div data-sp-canvascontrol=\\&quot;\\ » data-sp-canvasdataversion=\\&quot;1.0\\ » data-sp-controldata=\\&quot;{&quot;id » :&quot;8e21c4ab-d7e2-4f69-ac2e-8d8ba406ad72 »,&quot;controlType » :3,&quot;position » :{&quot;layoutIndex » :1,&quot;zoneIndex » :0.5,&quot;sectionIndex » :1,&quot;controlIndex » :1,&quot;sectionFactor » :0,&quot;zoneId » : » bcbd0b5b-f899-4314-89a8-d1bdc62d7c51&quot;},&quot;webPartId » :&quot;cbe7b0a9-3504-44dd-a3a3-0e5cacd07788 »,&quot;addedFromPersistedData » :true,&quot;reservedHeight » :228,&quot;reservedWidth » :968}\\&quot;><div data-sp-webpart=\\&quot;\\ » data-sp-webpartdataversion=\\&quot;1.6\\ » data-sp-webpartdata=\\&quot;{&quot;id » :&quot;cbe7b0a9-3504-44dd-a3a3-0e5cacd07788 »,&quot;instanceId » : » 8e21c4ab-d7e2-4f69-ac2e-8d8ba406ad72 »,&quot;title » :&quot;Bannière »,&quot;description » :&quot;Afficher une bannière avec le titre et les informations sur l’auteur »,&quot;audiences » :[],&quot;serverProcessedContent » :{&quot;htmlStrings » :{},&quot;searchablePlainTexts » :{},&quot;imageSources » :{&quot;imageSource » :&quot;https://cdn.hubblecontent.osi.office. net/m365content/publish/2cb5584a-d96c-451c-96cb-c429e16d2a9d/186678901.jpg&quot;},&quot;links » :{},&quot;customMetadata » :{&quot;imageSource » :{&quot;width » :3390,&quot;height » :2260}}},&quot;dataVersion » :&quot;1.6 »,&quot;properties » :{&quot;imageSourceType » :2,&quot;title » :&quot;L’allocation de vélo est mise à jour », « textAlignment » :&quot;Gauche »,&quot;showPublishDate » :true,&quot;authors » :[{&quot;id » :&quot;i :0#.f|membership|anouck@anfisolutions.be&quot; »,&quot;upn » :&quot;anouck@anfisolutions.be »,&quot;email » :&quot;anouck@anfisolutions.be&quot; »,&quot;name » :&quot;Anouck Fierens »,&quot;role » :&quot;&quot;}], « showTopicHeader » :false,&quot;authorByline » :[&quot;i :0#.f|membership|anouck@anfisolutions.be&quot;],&quot;layoutType » :&quot;FullWidthImage »,&quot;topicHeader » :&quot; »,&quot;enableGradientEffect » :true,&quot;isDecorative » :true,&quot;imgHeight » :2260,&quot;imgWidth » :3390},&quot;containsDynamicDataSource » :false}\\&quot;><div data-sp-componentid=\\&quot;cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\\&quot;></div><div data-sp-htmlproperties=\\&quot;\\&quot;><img data-sp-prop-name=\\&quot;imageSource\\ » src=\\&quot;https://cdn.hubblecontent.osi.office.net/m365content/publish/2cb5584a-d96c-451c-96cb-c429e16d2a9d/186678901.jpg\\ » data-sp-cust-width=\\&quot;3390\\ » data-sp-cust-height=\\&quot;2260\\ » /></div></div></div><div data-sp-canvascontrol=\\&quot;\\ » data-sp-canvasdataversion=\\&quot;1.0\\ » data-sp-controldata=\\&quot;{ » controlType » :4,&quot;id » :&quot;1212fc8d-dd6b-408a-8d5d-9f1cc787efbb »,&quot;position » :{&quot;controlIndex » :2,&quot;sectionIndex » :1,&quot;sectionFactor » :12,&quot;zoneIndex » :1,&quot;layoutIndex » :1,&quot;zoneId » :&quot;69398f3c-2220-4901-b4ff-5c9f1506b379&quot;},&quot;addedFromPersistedData » :true}\\&quot;><div data-sp-rte=\\&quot;\\&quot;><p style=\\&quot;margin-left :0in ;\\&quot;>Nous essayons d’avoir de plus en plus d’employés sur leurs vélos et nous avons de bonnes nouvelles à annoncer. L’indemnité vélo passera de 0,23 centime d’euro le kilomètre à 0,25 centime d’euro le kilomètre. Cela peut sembler une augmentation limitée, mais ceux qui se rendent au travail à vélo tous les jours remarqueront rapidement la différence sur leur fiche de paie. Continuez à faire du vélo !</p></div></div><div data-sp-canvascontrol=\\&quot;\\ » data-sp-canvasdataversion=\\&quot;1.0\\ » data-sp-controldata=\\&quot;{&quot;controlType » :0,&quot;pageSettingsSlice » :{&quot;isDefaultDescription » :false,&quot;isDefaultThumbnail » :false,&quot;isSpellCheckEnabled » :true,&quot;globalRichTextStylingVersion » :1,&quot;rtePageSettings » :{&quot;contentVersion » :5,&quot;indentationVersion » :2}, « isEmailReady » :false},&quot;htmlAttributes » :[&quot;modifiedDescription&quot;]}\\ » data-sp-meta-modifiedDescription=\\&quot;\\&quot;></div></div>&quot;}}"
            }
        }
    }
}
 
  • Expiscornovus Profile Picture
    31,652 Most Valuable Professional on 13 Feb 2025 at 13:22:56
    Translating and Saving Canvas Content as Draft
    Hi @Noek,
     
    I created a blog about this approach as well, if that helps?
     
    The general approach is that an apply to each loops through the items of the CanvasContent1 property.
     
    If it finds an innerHTML property which is not empty (checked in the condition action) it will go into the True section, translate text and append the translated Text/HTML to a temp array. If the item doesn't have any text to translate it will append the original item back to the same temp array.

  • Noek Profile Picture
    29 on 03 Jan 2025 at 11:07:23
    Translating and Saving Canvas Content as Draft
     
    I do the full canvascontent1. What is the best way to get online the innerhtml out of it and only translate that information.
  • Expiscornovus Profile Picture
    31,652 Most Valuable Professional on 03 Jan 2025 at 10:11:42
    Translating and Saving Canvas Content as Draft
    Hi @Noek,
     
    I assume you are you using the predictionOutput value? If that is the case the json value looks malformed/invalid, which might explain the BadGateway error.
     
    I see the » character is used a lot and also the quotes are not escaped. So, you might need to clean-up that json to turn it into valid json.

    Did you translate the full json or just the text/innerhtml of the Web Parts? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,776 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard
Loading started