Pulling URLs from infinite scroll SharePoint page

Copper Contributor

I'm trying to put together a list of articles and their URL from a corporate intranet that is built on SharePoint. These articles are displayed on pages titled with the name of each department followed by news -- so "Department A News", "Department B News", etc. The pages where they're shown are infinite scroll. Only a few items are shown initially and then more articles are shown as you scroll down until eventually all articles are shown. The URL for the page with the infinite scroll all have the following format:

 

https://<domain>.sharepoint.com/sites/<site>/_layouts/15/news.aspx?newsSource=3&instanceId=xxxxxxxx-...

 

Looking through the URL, it appears to have the following IDs built in:

  • instanceId
  • webPartId
  • serverRelativeUrl
  • pagesListId

I hoped the articles were just a list and that I could use pagesListId to grab them, but I got a "Enter a valid integer." error when I tried using "Get item" with the pagesListId.

 

I tried using "Send an HTTP request to SharePoint" using the full URL in the uri like:

 

_api/search/query?querytext='path: https://<domain>.sharepoint.com/sites/<site>/_layouts/15/news.aspx?newsSource=3&instanceId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&webPartId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&serverRelativeUrl=%2Fsites%2F<site>&pagesListId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

 

That gave me an error that read "The query string "querytext" is missing or invalid."

 

Any idea how to pull from these kinds of SharePoint sites?

 

 

 

 

1 Reply
The "pageslistid" is the internal id of your sitepages library.

The "news.aspx" page aggregates all news articles from the given sources and each news article is a single file in the sitepages library with the property promotedState set to 2.

I understand that you want to fetch the list of the articles... You could try to use SharePoint Search for that

/_api/search/query?querytext='IsDocument:True AND FileExtension:aspx AND PromotedState:2 Path:<Sitecollections you want the news from>'&selectproperties='Description,PictureThumbnailURL,CanvasContent1OWSHTML'

You will get the properties "Description" and "PictureThumbnailURL" containing the teaser text and the teaser image for each news article from the search results.
The Property "CanvasContent1OWSHTML" will contain the entire single news artigle encoded as an html file