Forum Discussion

roshan08's avatar
roshan08
Copper Contributor
Sep 13, 2023

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.

  • Nishkalank's avatar
    Nishkalank
    Copper Contributor

    Hey roshan08 

    You can use SharePoint Search API to fetch all the news pages from specific sites as below

     

     

    https://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

  • roshan08 

     

    1. Where are you trying to pull the news posts, SPFx or Power Automate/Apps or anywhere else?
    2. 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=*

     

    ReferenceHow 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_Elliott's avatar
    Rob_Elliott
    Bronze 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)

Resources