Forum Discussion
API to do Like/Unlike of Comments in SharePoint Modern Page
Hi,
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.
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).like(); 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!
Regards.
- Carlos_MarinsIron 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).like(); 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!
Regards.