web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Problems creating a ne...
Power Automate
Unanswered

Problems creating a news post when a list item is created

(0) ShareShare
ReportReport
Posted on by 49

I found this solved post about creating a news post when a list item is created and am trying to implement it. Screenshots of my entire flow are below. But I'm running into two issues. 

  1. Every time I run the flow, two pages are created. I'll get something like Test 01.aspx and Test–01.aspx
  2. Every time I run the flow and have dynamic content in the 'innerHTML' (the yellow highlighted part in the second screenshot) the flow fails at the last action. I get a BadGateway error. Below the screenshots is the output of the error.

Any insight would be appreciated.

 

Tagging @Expiscornovus since he created the original solution I'm working off of.

 

Picture001.png

 

 

Picture002.png

 

{
 "statusCode": 502,
 "headers": {
 "Pragma": "no-cache",
 "Cache-Control": "no-store, no-cache",
 "Set-Cookie": "ARRAffinity=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net,ARRAffinitySameSite=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net",
 "x-ms-datasourceerror": "True",
 "x-ms-request-id": "2b11b8a0-d019-3000-a9e0-810ec1592287",
 "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
 "X-Content-Type-Options": "nosniff",
 "X-Frame-Options": "DENY",
 "Timing-Allow-Origin": "*",
 "x-ms-apihub-cached-response": "true",
 "x-ms-apihub-obo": "false",
 "Date": "Tue, 30 May 2023 23:02:17 GMT",
 "Content-Length": "750",
 "Content-Type": "application/json",
 "Expires": "-1"
 },
 "body": {
 "error": {
 "code": 502,
 "source": "flow-apim-msmanaged-na-westus2-01.azure-apim.net",
 "clientRequestId": "cb13ed9a-55ed-4af3-ad26-2be8e6a95c2c",
 "message": "BadGateway",
 "innerError": {
 "status": 502,
 "message": "There was an error deserializing the object of type Microsoft.SharePoint.Publishing.SitePageFieldsData. Encountered unexpected character 'E'.\r\nclientRequestId: cb13ed9a-55ed-4af3-ad26-2be8e6a95c2c\r\nserviceRequestId: 2b11b8a0-d019-3000-a9e0-810ec1592287",
 "source": "https://salemhealth.sharepoint.com/sites/Daily_Dose/_api/sitepages/pages(367)/SavePageAsDraft",
 "errors": [
 "-1",
 "System.Runtime.Serialization.SerializationException"
 ]
 }
 }
 }
}

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @Collinjay,

     

    Are you escaping the quotes in the dynamic content you are using within the innerHTML property? Can you also share the HTML you are using in your test?

  • Collinjay Profile Picture
    49 on at

    Hi @Expiscornovus,

     

    I believe I'm escaping the quotes... Below is everything within the 'body' field, including dynamic content within the innerHTML property.

     

    At this point, I'm testing the flow with text only in the SharePoint list form — so the html I'm using is something like <div>Lorem ipsum</div> or <p>Lorem ipsum</p>.

     

    {
     "LayoutWebpartsContent":"[{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"\\n Title area\\n \",\"description\":\"\\n Title area description\\n \",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"https://cdn.hubblecontent.osi.office.net/m365content/publish/f9acda13-4460-426f-b4d9-5fb9b34b47d0/613871602_super.jpg\"},\"links\":{},\"customMetadata\":{\"imageSource\":{\"width\":2048,\"height\":1152}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"@{triggerOutputs()?['body/Title']}\",\"textAlignment\":\"Left\",\"showPublishDate\":true,\"authors\":[],\"showTopicHeader\":true,\"authorByline\":[],\"layoutType\":\"FullWidthImage\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"News & Notices\",\"enableGradientEffect\":true,\"imgHeight\":1152,\"imgWidth\":2048,\"translateX\":58.70870870870871,\"translateY\":49.122807017543856},\"containsDynamicDataSource\":false,\"reservedHeight\":228}]",
     "CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":1,\"sectionIndex\":1,\"sectionFactor\":8,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"@{triggerOutputs()?['body/Article']}\"},{\"position\":{\"controlIndex\":1,\"sectionIndex\":2,\"sectionFactor\":4,\"zoneIndex\":1,\"layoutIndex\":1},\"controlType\":3,\"id\":\"1856c2ad-84c5-43c3-8f12-f353dbbd8f5b\",\"webPartId\":\"8c88f208-6c77-4bdb-86a0-0c47b4316588\",\"reservedHeight\":424,\"reservedWidth\":364,\"addedFromPersistedData\":true,\"webPartData\":{\"id\":\"8c88f208-6c77-4bdb-86a0-0c47b4316588\",\"instanceId\":\"1856c2ad-84c5-43c3-8f12-f353dbbd8f5b\",\"title\":\"News\",\"description\":\"Show news posts from one or more sites in a variety of layouts. You can filter news and target news to key audiences.\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{\"title\":\"Latest news\"},\"imageSources\":{},\"links\":{\"baseUrl\":\"https://---redacted---.com/sites/--redacted--\"}},\"dataVersion\":\"1.12\",\"properties\":{\"carouselSettings\":{\"autoplay\":false,\"autoplaySpeed\":5,\"dots\":true,\"lazyLoad\":true,\"metadata\":true,\"swipe\":true,\"useStockItems\":false},\"showChrome\":true,\"showNewsMetadata\":{\"showSocialActions\":false,\"showAuthor\":false,\"showDate\":true},\"layoutId\":\"ListNews\",\"newsDataSourceProp\":1,\"filterKQLQuery\":\"\",\"carouselHeroWrapperComponentId\":\"\",\"prefetchCount\":6,\"filters\":[{\"filterType\":1,\"value\":\"\",\"values\":[]}],\"dataProviderId\":\"news\",\"newsSiteList\":[],\"renderItemsSliderValue\":6,\"layoutComponentId\":\"\",\"webId\":\"58859736-b09f-40df-9531-773e4f35c58b\",\"siteId\":\"90398e7f-8163-4ca7-a651-075d4b04af92\",\"pinnedItems\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],\"templateId\":\"ListNews\",\"propsLastEdited\":\"2023-01-16T19:27:18.269Z\",\"compactMode\":true},\"containsDynamicDataSource\":false}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true,\"isSpellCheckEnabled\":true,\"globalRichTextStylingVersion\":1,\"rtePageSettings\":{\"contentVersion\":4},\"isEmailReady\":false}}]",
     "AuthorByline":[
     
     ],
     "TopicHeader":"News & Notices",
     "BannerImageUrl":"https://cdn.hubblecontent.osi.office.net/m365content/publish/f9acda13-4460-426f-b4d9-5fb9b34b47d0/613871602_super.jpg",
     "Title":"@{triggerOutputs()?['body/Title']}"
    }
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @Collinjay,

     

    What settings did you use for the Article column in your source list? I used a Multiple lines of text without any additional settings (like Rich Text).

     

    article_columnsettings.png

     

    I just tested a similar setup and I got this as the end result.

     

    loremimpsum.png

     

    The payload I used is slightly different. I wanted to start simple to see if the approach still works. Maybe you can test it with the same setup?

     

    {
    "LayoutWebpartsContent":"[{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"\\n Title area\\n \",\"description\":\"\\n Title area description\\n \",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[{\"id\":\"\",\"upn\":\"\",\"email\":\"\",\"name\":\"\",\"role\":\"\"}],\"showTopicHeader\":false,\"authorByline\":[\"\"],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\"},\"reservedHeight\":356}]","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"@{triggerOutputs()?['body/Article']}\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{triggerOutputs()?['body/Title']}"}

     

    Also worth mentioning is that the Content-Type header I used has the odata=nometadata value (in this test, but also in my original post back in 2021).

     

    {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json;odata=nometadata"
    }

     

    savepageasdraft_repro.png

  • Collinjay Profile Picture
    49 on at

    Hi @Expiscornovus,

     

    I updated my flow to match your suggested setup and tested a few times. It both worked and didn't work.

    • It worked when the Article field was set to 'Multiple Lines of Text' and 'Rich Text' was turned off.
    • It did not work when Article field was set to 'Multiple Lines of Text' and 'Rich Text' was turned on. 

     

    I'm hoping to make this flow work with Rich Text turned on. I have a list of nearly 4000 items that I'm moving to a new site, and I want these 4000 items to become pages on the destination site. All these items are coming into the destination site with html in the Article field. Is this something I can accomplish with this flow?

  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @Collinjay,

     

    Just to double check. Can you explain why that Rich Text is a requirement?

     

    Earlier you shared that you where using HTML tags as input directly in the multi line field. In that case you wouldn't need Rich Text, correct?

     

    In the meantime I will have a look if I can get it working with Rich Text. It might be that some conversion is required to turn the rich text into valid HTML again.

  • slawo88 Profile Picture
    14 on at

    @Collinjay @Expiscornovus ,

     

    Just wondering if you manage to solve this?

    I have exactly the same issue when creating sited from list entry with Rich text

  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @slawo88,

     

    Like mentioned in my previous reply. I would suggest to use a multiples lines of text field in the CMS source list with Rich Text disabled.

     

    There is no point in using Rich Text if the aim is to write the HTML yourself in the field.

  • slawo88 Profile Picture
    14 on at

    @Expiscornovus , got ya,

     

    I managed to store the text in table w. html tags

     

    2023-08-21 18_50_37-departament-site-test - SPO Sites - All Items and 14 more pages - Work 3 - Micro.png

     

    But when flow is being triggered it is giving me BadGateway error as well

     

    {
    "LayoutWebpartsContent":"[{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"\\n Title area\\n \",\"description\":\"\\n Title area description\\n \",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test\",\"textAlignment\":\"Left\",\"showPublishDate\":true,\"authors\":[{\"id\":\"\",\"upn\":\"\",\"email\":\"\",\"name\":\"\",\"role\":\"\"}],\"showTopicHeader\":true,\"authorByline\":[\"\"],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\"},\"reservedHeight\":356}]","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"@{outputs('Compose')}\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{triggerOutputs()?['body/Title']}"}

     

     

  • slawo88 Profile Picture
    14 on at

    Neverminded,

     

    I found solution here: Automate Modern SharePoint Page Creation Using Power Automate (c-sharpcorner.com)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard