Create News Posts with Power Automate and SharePoint Automagically

Опубликовано: 10 Февраль 2025
на канале: Andrew Hess
3,000
49

Creating news posts automatically with Power Automate can be achieved with a sequence of four HTTP requests. The first request copies the template for the news post, the second checks out the news post for editing, the third writes and saves a draft, and the fourth publishes the post. This streamlined process ensures efficient and accurate news posting with minimal manual effort.

This was a common question on many forums so I thought we could put something together for a video! Thank you all for watching!

My name is Andrew Hess, please like and subscribe!

Chapters:
0:42 Create Template
1:53 Power Automate
2:37 HTTP Request Copy Template
4:11 Get File Metadata using path
5:10 HTTP Request CheckOut
6:30 HTTP Request Write and Save
8:40 HTTP Request Publish
10:20 Testing Results



Copy Template
/_api/web/getfilebyserverrelativeurl('/sites/automagic/sitepages/template.aspx')/copyto('/sites/automagic/sitepages/@{triggerBody()?['Title']}.aspx')

CheckOut
/_api/sitepages/pages(@{outputs('Get_file_metadata_using_path')?['body/ItemId']})/checkoutpage

Write and Save
/_api/sitepages/pages(@{outputs('Get_file_metadata_using_path')?['body/ItemId']})/SavePageAsDraft

{
"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\":\"We are going to write a long news post that we will be able to see the body of the content and make sure that it has lots of space this could be a power app or a email who knows what it could be but this is my body. \",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{triggerBody()?['Title']}"}


Publish
_api/sitepages/pages(@{outputs('Get_file_metadata_using_path')?['body/ItemId']})/Publish