Forum Discussion
roshan08
Sep 13, 2023Copper Contributor
API to pull all news post from sharepoint online site
Hi Team,
Can we have API to pull all news post or all .aspx pages from sharepoint site.
- NishkalankCopper Contributor
Hey roshan08
You can use SharePoint Search API to fetch all the news pages from specific sites as belowhttps://xxx.sharepoint.com/_api/search/query?querytext='SPContentType:"Site Page" AND IsDocument:True AND FileExtension:aspx AND PromotedState:2 AND FirstPublishedDate=today AND Path:https://xxx.sharepoint.com/sites/xxx OR Path:https://xxx.sharepoint.com/sites/xxx OR Path:https://xxx.sharepoint.com/sites/xxx/SitePages'&sortlist='FirstPublishedDate:descending'&startRow=0&rowlimit=100&selectproperties='Title,Description,RefinableString03,FirstPublishedDate,PictureThumbnailURL,WebId,Path'
There is a possibility to use Graph API as well that you may try it.Thanks,
Nishkalank Bezawada - Where are you trying to pull the news posts, SPFx or Power Automate/Apps or anywhere else?
- What information related to news posts do you need, page name/other column values, etc.?
You can use generic SharePoint REST API like below to get the page items from Site pages library:
<siteUrl>/_api/Web/Lists/getByTitle('Site Pages')/items?$select=*
Reference: How to fetch only Site Pages and not page templates from Site Pages library using REST call?
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Rob_ElliottBronze Contributor
roshan08 Any particular reason you need an api? A simple flow in Power Automate can do this easily.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP UK (and classic 1967 Morris Traveller driver)