Introduction
In this article we will consume a WHO RSS feed and generate SharePoint News Pages. For that we will use power automate flow which will run every day and generate SharePoint news pages for us. So,let's start.
Git Repo
For high resolution screenshots
Output
Steps
Link of WHO RSS Feed.
I am assuming that you have basic knowledge of SharePoint and power automate.
Step 1
Create new SharePoint communication site.
Step 2
Create new News Post in SharePoint communication site for template purposes so we can take post structure metadata of it.
To take metadata one way is to open browser dev tool (inspect element) before publishing the template post and then publish the post. You will find one request in Network tab named as “Save Page” which contains the request payload in json format.
Copy it in some notepad file to use it ilater on. Please see the below screenshots so you can understand it easily.
At finally I have renamed the post as WHOTemplate.aspx.
Step 3
Now it’s time to create Power Automate flow which runs daily and checks for new RSS feeds and create SharePoint news posts accordingly.
Step 4
Below are the steps which the consume WHO RSS feed and check for the posts created today and generate news post using our createdWHOTemplate.aspx.
- Initialize variable Today
formatDateTime(utcNow(),'yyyy-MM-dd')
- List all RSS feed items
https://www.who.int/rss-feeds/news-english.xml
- Apply to each
Repeat for all items in RSS Feed
- Condition if RSS feed item published today
indexOf(items('Apply_to_each')?['publishDate'],variables('Today'))
- Step 5 – if YES
- Compose JSON compatible file content (replacing " with \\\" because it breaks json)
replace(uriComponent(items('Apply_to_each')?['summary']), '%22', '%5C%5C%5C%22')
- Compose removed new lines (removing new lines)
uriComponentToString(replace(replace(outputs('Compose_JSON_compatible_file_content'), '%0D%0A', ''), '%0A', ''))
- Send an HTTP request to create file
_api/web/getfilebyserverrelativeurl('/sites/WHONews/SitePages/WHOTemplate.aspx')/copyto(strnewurl='/sites/WHONews/SitePages/@{items('Apply_to_each')?['title']}.aspx',bOverwrite=true)
- Get file metadata of newly created file
SitePages%2f @{items('Apply_to_each')?['title']}.aspx
- Send an HTTP request to checkout newly created file
_api/SitePages/pages(@{outputs('Get_file_metadata_of_newly_created_file')?['body/ItemId']})/checkoutpage
{
"content-type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose"
}
- Send an HTTP request to SharePoint to add RSS feed content to file
_api/SitePages/pages(@{body('Get_file_metadata_of_newly_created_file')?['ItemId']})/SavePageAsDraft
{
"content-type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose"
}
Put meta data and replace the content where you need dynamic content please see screenshot
- Send an HTTP request to SharePoint for publish newly created file
_api/SitePages/pages(@{body('Get_file_metadata_of_newly_created_file')?['ItemId']})/Publish
{
"content-type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose"
}
Save and run the flow.