Sharepoint REST api - post a like on a site page comment

matt howell 3,496 Reputation points
2021-06-28T20:04:55.34+00:00

I can like a page using:
/_api/web/lists/getByTitle('SitePages')/GetItemById(722)/like

Modern pages also allow users to like a comment but this api call doesn't work:
/_api/web/lists/getByTitle('SitePages')/GetItemById(<pageid>)/Comments(<commentid>)/like

Error:
"error": {
"code": "-2147024891, System.UnauthorizedAccessException",
"message": {
"lang": "en-US",
"value": "Attempted to perform an unauthorized operation."
}

For this function Msft references a really long ID - but surely there's an easier way?
"ID":"1.94fdcc5fc39b4a2c99ae4570caf02321.d0a03fb1761a404a9a8e7f9f5ec58e17.5a1067e8af65410b9e2ba6a74a4b718a.0c37852b34d0418e91c62ac25af4be5b.9dbfb5598e2248d7b57eee57abf2e7c1.31.31.S-1-5-21-124525095-708259637-1543119021-565461"

There's no id like this in the comments json response - the comments "id" is a simple integer.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. MichaelHan-MSFT 18,136 Reputation points
    2021-06-29T06:08:13.65+00:00

    Hi, @matt howell ,

    Just did a test on my end, the like a comment endpoint worked well for me. From the error message, looks like you do not have enough access to like a comment.

    110075-image.png


    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.