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 / Creating a site page f...
Power Automate
Unanswered

Creating a site page from a SharePoint list using Send an HTTP request which gives a 502 bad gateway error.

(0) ShareShare
ReportReport
Posted on by 546

Hi everyone,  I'm struggling with a workflow that is attempting to copy list data to a site page based on this YouTube video: 

https://youtu.be/QtBqeEEOgdE 

Apologies for the length of this one.  I figured better to be thorough.  The 502 error is in the final step.  The page does get created but without the list information.

 

Here is the 502 error:

{
  "error": {
    "code"502,
    "source""flow-apim-msmanaged-na-northcentralus-01.azure-apim.net",
    "clientRequestId""2ef6cea8-ea4d-41d6-9898-000b7b0c4c86",
    "message""BadGateway",
    "innerError": {
      "status"502,
      "message""There was an error deserializing the object of type Microsoft.SharePoint.Publishing.SitePageFieldsData. Encountered unexpected character 'S'.\r\nclientRequestId: 2ef6cea8-ea4d-41d6-9898-000b7b0c4c86\r\nserviceRequestId: 7cdb10a1-c082-4000-fe15-bbf9e34dda92",
      "errors": [
        "-1",
        "System.Runtime.Serialization.SerializationException"
      ]
    }
  }
}

Here is the JSON payload:

{__metadata: {type: "SP.Publishing.SitePage"},…}
AuthorByline
:
["i:0#.f|membership|myemail@work.ca"]
BannerImageUrl
:
"/_layouts/15/images/sitepagethumbnail.png"
CanvasContent1
:
"[{\"controlType\":4,\"id\":\"64a5d11d-9c56-46fe-a344-25520738dfbd\",\"position\":{\"layoutIndex\":1,\"zoneIndex\":1,\"sectionIndex\":1,\"sectionFactor\":12,\"controlIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"<p>Employee name: {Nominee}</p><p>Department: {Nominee Unit}</p><p>Description: {One to three lines…}</p>\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true,\"isSpellCheckEnabled\":true,\"globalRichTextStylingVersion\":1,\"rtePageSettings\":{\"contentVersion\":5},\"isEmailReady\":false}}]"
LayoutWebpartsContent
:
"[{\"id\":\"1ee8960a-2fa0-4145-b9bb-e818f6cf18e7\",\"instanceId\":\"1ee8960a-2fa0-4145-b9bb-e818f6cf18e7\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{\"baseUrl\":\"https://dalu.sharepoint.com/sites/medit-development\"},\"componentDependencies\":{\"layoutComponentId\":\"8ac0c53c-e8d0-4e3e-87d0-7449eb0d4027\"}},\"dataVersion\":\"1.0\",\"properties\":{\"hideWebPartWhenEmpty\":true,\"isEditMode\":true,\"isEnabled\":false,\"layoutId\":\"FilmStrip\",\"uniqueId\":\"06d47312-1d46-4845-b416-2da516f056c9\",\"dataProviderId\":\"RecommendedItems\",\"webId\":\"f178f91e-6af0-49fe-aace-54bd48f44d7b\",\"siteId\":\"d4e8407f-c386-4f50-b936-1c6766c25266\"},\"containsDynamicDataSource\":false,\"reservedHeight\":356},{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"Title area\",\"description\":\"Title Region Description\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{}},\"dataVersion\":\"1.4\",\"properties\":{\"title\":\"getpayload\",\"imageSourceType\":4,\"layoutType\":\"FullWidthImage\",\"textAlignment\":\"Left\",\"showTopicHeader\":false,\"showPublishDate\":false,\"topicHeader\":\"\",\"enableGradientEffect\":true,\"isDecorative\":true,\"authors\":[{\"id\":\"i:0#.f|membership|medcomm@dal.ca\",\"upn\":\"myemail@work.ca\",\"email\":\"myemail@work.Ca\",\"name\":\"Medical My work Email\",\"role\":\"Me at work\"}],\"authorByline\":[\"i:0#.f|membership|myemail@work.ca\"],\"hasTitleBeenCommitted\":true},\"containsDynamicDataSource\":false,\"reservedHeight\":280}]"
Title
:
"getpayload"
TopicHeader
:
""
__metadata
:
{type: "SP.Publishing.SitePage"}

 

Here is the flow: 

smorley_0-1709566140185.png

 

 

smorley_1-1709566140186.png

 

smorley_2-1709566140187.png

 

 

encodeUriComponent(concat('/SitePages/',replace(triggerOutputs()?['body/Title'], ' ', ' '),'.aspx')) 

 

Note: the original syntax from the blog gave a file not found error so I removed ‘-’. encodeUriComponent(concat('/SitePages/',replace(triggerOutputs()?['body/Title'], ' ', '-'),'.aspx')) as a result of this post: https://powerusers.microsoft.com/t5/Building-Flows/Get-file-metadata-failed-Route-did-not-match/td-p/1806612 

smorley_3-1709566140188.png

 

 

This step uses the ItemId from the get metadata step. 

 

smorley_4-1709566140189.png

 

 

This step also uses the ItemId from the get metadata step. 

 

Here are the steps from the video: (seen at 1:14 for the first 6 steps) 

  1. Create a news page template 
  2. Create a sample page and publish it. 
  3. Publish page, copy Payload in a NotePad file. 
  4. Create a flow. 
  5. Add a Send HTTP action: 
  6. Add the Title field from the list for the new page name. smorley_5-1709566172877.png

     

     
  7. These steps are shown at (11:18 of the video) Get file identifier with this very specific syntax - SitePage%2f/@{triggerBody()?[‘Title’]}.aspx 
  8. The expression syntax of this syntax encodeUriComponent(concat('/SitePages/',replace(triggerOutputs()?['body/Title'], ' ', '-'),'.aspx')) needed to be changed to prevent a file not found error. I removed the dash and then it worked. smorley_6-1709566172878.png

     

     
  9. Next check the page out. smorley_7-1709566172879.png

     

     
  10. The final step takes the payload referenced above, which is a JSON file. (I’m not going to copy the entire JSON for clarity purposes.) The ItemID is also from the get file metadata step above. 

 

 

The JSON is:  

 

 

{__metadata: {type: "SP.Publishing.SitePage"},…} 

AuthorByline 

:  

["i:0#.f|membership|medcomm@dal.ca"] 

BannerImageUrl 

:  

"/_layouts/15/images/sitepagethumbnail.png" 

CanvasContent1 

:  

"[{\"controlType\":4,\"id\":\"64a5d11d-9c56-46fe-a344-25520738dfbd\",\"position\":{\"layoutIndex\":1,\"zoneIndex\":1,\"sectionIndex\":1,\"sectionFactor\":12,\"controlIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"<p>Employee name: {Nominee}</p><p>Department: {Nominee Unit}</p><p>Description: {One to three lines…}</p>\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true,\"isSpellCheckEnabled\":true,\"globalRichTextStylingVersion\":1,\"rtePageSettings\":{\"contentVersion\":5},\"isEmailReady\":false}}]" 

LayoutWebpartsContent 

:  

"[{\"id\":\"1ee8960a-2fa0-4145-b9bb-e818f6cf18e7\",\"instanceId\":\"1ee8960a-2fa0-4145-b9bb-e818f6cf18e7\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{\"baseUrl\":\"https://dalu.sharepoint.com/sites/medit-development\"},\"componentDependencies\":{\"layoutComponentId\":\"8ac0c53c-e8d0-4e3e-87d0-7449eb0d4027\"}},\"dataVersion\":\"1.0\",\"properties\":{\"hideWebPartWhenEmpty\":true,\"isEditMode\":true,\"isEnabled\":false,\"layoutId\":\"FilmStrip\",\"uniqueId\":\"06d47312-1d46-4845-b416-2da516f056c9\",\"dataProviderId\":\"RecommendedItems\",\"webId\":\"f178f91e-6af0-49fe-aace-54bd48f44d7b\",\"siteId\":\"d4e8407f-c386-4f50-b936-1c6766c25266\"},\"containsDynamicDataSource\":false,\"reservedHeight\":356},{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"Title area\",\"description\":\"Title Region Description\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{}},\"dataVersion\":\"1.4\",\"properties\":{\"title\":\"getpayload\",\"imageSourceType\":4,\"layoutType\":\"FullWidthImage\",\"textAlignment\":\"Left\",\"showTopicHeader\":false,\"showPublishDate\":false,\"topicHeader\":\"\",\"enableGradientEffect\":true,\"isDecorative\":true,\"authors\":[{\"id\":\"i:0#.f|membership| myworkemail@email.ca \",\"upn\":\"medcomm@dal.ca\",\"email\":\"MyWorkemail@email.Ca\",\"name\":\"My Work Email\",\"role\":\"My work email\"}],\"authorByline\":[\"i:0#.f|membership|myworkemail@email.ca\"],\"hasTitleBeenCommitted\":true},\"containsDynamicDataSource\":false,\"reservedHeight\":280}]" 

Title 

:  

"getpayload" 

TopicHeader 

:  

"" 

__metadata 

:  

{type: "SP.Publishing.SitePage"} 

Categories:
I have the same question (0)
  • smorley Profile Picture
    546 on at

    @Expiscornovus - any ideas?

  • Verified answer
    Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @smorley,

     

    It looks like the json used in the Body field is invalid. It is a bit difficult to track down which section is causing is. 

     

    I have seen a lot of cases where the InnerHtml value was invalid, so I would suggest to look at that as well. Try and use different HTML and see if that works?

     

    The easiest way to troubleshoot this is to start small. First add a custom title and gradually add more and more content to your page. This way you would know what is causing this. You are using the below format for the Body, correct?

     

    {
    "__metadata":{"type":"SP.Publishing.SitePage"},
    "LayoutWebpartsContent":"[]",
    "CanvasContent1":"[]",
    "AuthorByline":[""],
    "TopicHeader":"",
    "BannerImageUrl":"",
    "Title":""
    }

     

  • smorley Profile Picture
    546 on at

    Ok well that definitely helped.  I had to remove the double quotes inside the author by line part.  Next step?

    I just added my original canvas content and that worked.

     @Expiscornovus 

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 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard