Sharepoint REST api get page contents and all likedbyinformation

matt howell 341 Reputation points
2021-07-23T18:38:41.11+00:00

I'd like to have one call that gets all page content AND details for the page's likes (count and the users who liked). This call returns LikedByInformation but shows no likes (when there are likes for the page) and doesn't include any details. Seems like it's just getting info from the rating column which isn't used in modern pages.

/_api/web/lists/getbytitle('Site Pages')/items?$select=Title,FileRef,FirstPublishedDate,CanvasContent1,Videourl,BannerImageUrl,OData__AuthorByline/Title,likedByInformation&$expand=likedByInformation,LikedBy,OData__AuthorByline&$filter=ID eq '250'

This call does return the like details but not the page contents for obvious reasons:

/_api/web/lists/getbyTitle('Site Pages')/GetItemById(1)/likedByInformation?$expand=likedby&$select=likedby,Title,FileRef,FirstPublishedDate,CanvasContent1,Videourl,BannerImageUrl,OData__AuthorByline/Title

Including "LikedBy" in the $select option just returns an error that the property doesn't exist presumably because likes aren't a property in the site pages library.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,803 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,031 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,036 Reputation points
    2021-07-26T02:57:14.447+00:00

    Hi @matt howell ,

    Per my test, I got the same result as yours on my end. We cannot get all those information in one call.

    You need to send two different request calls to acheve this, one for page content, one for likedbyinformation.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.