API to do Like/Unlike of Comments in SharePoint Modern Page

Steel Contributor



Is there any API/way available for SharePoint Online using which we can like/unlike particular comment/reply of SharePoint Modern Page? Till now I got only is we can read information about like of comments/replies but didn't find any API about updating like information of comments/reply.

1 Reply
best response confirmed by kalpeshvaghela (Steel Contributor)

Hey @kalpeshvaghela ,


You can use the PnPJS library to like/comment a page comment, too. Check out the documentation here.


Basically, after you have the comment ID, you can make these call to like/add a comment to an already existing comment.


      sp.web.lists.getByTitle(listID).items.getById(pageId).comments.getById(commentId).replies.add('here is some text');


It worth noting that you can't add a reply to a reply, though. Hope this helps!