Hi all!
I am trying to get a flow to create a news post on Sharepoint. Everything seems to be triggering correctly, but the Sharepoint page that is created is totally empty.
I suspect that this is due to the code used in the body:
{
"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\":\"@{outputs('Get_message_details')?['body/body/content']}\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{outputs('Get_message_details')?['body/subject']}"}
Screenshots of the flow:
Any ideas or suggestions on how to make this work?
Solved! Go to Solution.
Hi @flavioPBadmin :
Please check the value of 'innerHTML'(Please use plain HTML text, do not add anything else). I've made a test and it worked well:
{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test nº 999\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"Test nº 999","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"<P>Hi bof</P>\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}
The Result:
Best Regards,
Bof
Hi @flavioPBadmin ,
I've made a test but it worked well on my side:
Please try this body:
{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"@{variables('PageName')}\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"@{variables('PageName')}","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"@{outputs('Compose')}\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}
Best Regards,
Bof
Just a question. How do I do to solve the error, I can't seem to be able to initialize a variable anywhere.
"The variable 'PageName' must be initialized before it can be used inside action 'Send_an_HTTP_request_to_SharePoint_3'.'." ?
After some trial and error, I have gotten to this body:
{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"@{outputs('Get_message_details')?['body/subject']}\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"@{outputs('Get_message_details')?['body/subject']}","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"@{outputs('Compose')}\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}
Which outputs this:
{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test nº 999\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"Test nº 999","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#teams('9893b60b-98f1-479a-a274-71cabc0e8a18')/channels('19%3AXg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1%40thread.tacv2')/messages/$entity","id":"1650377165586","replyToId":null,"etag":"1650377165586","messageType":"message","createdDateTime":"2022-04-19T14:06:05.586Z","lastModifiedDateTime":"2022-04-19T14:06:05.586Z","lastEditedDateTime":null,"deletedDateTime":null,"subject":"Test nº 999","summary":null,"chatId":null,"importance":"normal","locale":"en-us","webUrl":"https://teams.microsoft.com/l/message/19%3AXg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1%40thread.tacv2/1650377165586?groupId=9893b60b-98f1-479a-a274-71cabc0e8a18&tenantId=ce0df492-7f32-43cf-b297-ee135760da1b&createdTime=1650377165586&parentMessageId=1650377165586","policyViolation":null,"eventDetail":null,"from":{"application":null,"device":null,"user":{"id":"a7fcb8b1-a5cc-4133-9756-f48cfff228d6","displayName":"Flavio Neto","userIdentityType":"aadUser"}},"body":{"contentType":"html","content":"<div>\n<div itemprop=\"copy-paste-block\">\n\n<div style=\"font-size:14px\">\n\n<p><span style=\"font-size:12pt\"><span>Hi everyone!</span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span></span></span> </p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>In our effort to streamline our working relationships, I would like to ask everyone to start using this team’s calendar to note down anything that might impact the whole team like, for example, create a recurring event regarding when you are regularly away from your desk, or working in another personal projects or jobs. </span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>As most of us have different work schedules, sometimes radically so, it would help us as a team to share those timings and lay them out. </span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>I would also ask for everyone to put down their annual leave dates and any other team relevant events. </span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>Of course, you can still access other people’s personal calendars, and see their availability, but this method can give us, briefly, an idea of how much of our team is available and when.</span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span></span></span> </p>\n\n\n\n<p><span style=\"font-size:12pt\"><span> Please see mine and Adam’s entries in the calendar as an example.</span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span> #NEWS</span></span></p>\n\n</div>\n</div>\n</div>","plainTextContent":"\n\n\n\n\nHi everyone!\n\n\n\n \n\n\n\nIn our effort to streamline our working relationships, I would like to ask everyone to start using this team’s calendar to note down anything that might impact the whole team like, for example, create a recurring event regarding when you are regularly away from your desk, or working in another personal projects or jobs. \n\n\n\nAs most of us have different work schedules, sometimes radically so, it would help us as a team to share those timings and lay them out. \n\n\n\nI would also ask for everyone to put down their annual leave dates and any other team relevant events. \n\n\n\nOf course, you can still access other people’s personal calendars, and see their availability, but this method can give us, briefly, an idea of how much of our team is available and when.\n\n\n\n \n\n\n\n Please see mine and Adam’s entries in the calendar as an example.\n\n\n\n #NEWS\n\n\n\n"},"channelIdentity":{"teamId":"9893b60b-98f1-479a-a274-71cabc0e8a18","channelId":"19:Xg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1@thread.tacv2"},"attachments":[],"mentions":[],"reactions":[],"messageLink":"https://teams.microsoft.com/l/message/19%3AXg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1%40thread.tacv2/1650377165586?groupId=9893b60b-98f1-479a-a274-71cabc0e8a18&tenantId=ce0df492-7f32-43cf-b297-ee135760da1b&createdTime=1650377165586&parentMessageId=1650377165586","threadType":"channel","teamId":"9893b60b-98f1-479a-a274-71cabc0e8a18","channelId":"19:Xg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1@thread.tacv2"}\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}
But still creates pages like this:
Hi @flavioPBadmin ,
Cause you did not Initialize the variable 'PageName'. If you want to specify the name of the Page directly, then you can replace
@{variables('PageName')}
with any string you want.
Best Regards,
Bof
Hi @v-bofeng-msft,
Yes, that was what I did, and it generated the code in the post above, but the pages are still empty and I can't understand why.
Best regards,
Flávio
Best regards
Hi @flavioPBadmin :
Please check the value of 'innerHTML'(Please use plain HTML text, do not add anything else). I've made a test and it worked well:
{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test nº 999\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"Test nº 999","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"<P>Hi bof</P>\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}
The Result:
Best Regards,
Bof
Thanks, that worked, now I just have to sort out how to get the body and the subject of the Teams message unto there. Will test out some ideas and come back later.
User | Count |
---|---|
97 | |
40 | |
27 | |
23 | |
16 |
User | Count |
---|---|
130 | |
51 | |
48 | |
36 | |
24 |