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

%3CLINGO-SUB%20id%3D%22lingo-sub-1301850%22%20slang%3D%22en-US%22%3EAPI%20to%20do%20Like%2FUnlike%20of%20Comments%20in%20SharePoint%20Modern%20Page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1301850%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20API%2Fway%20available%20for%20SharePoint%20Online%20using%20which%20we%20can%20like%2Funlike%20particular%20comment%2Freply%20of%20SharePoint%20Modern%20Page%3F%20Till%20now%20I%20got%20only%20is%20we%20can%20read%20information%20about%20like%20of%20comments%2Freplies%20but%20didn't%20find%20any%20API%20about%20updating%20like%20information%20of%20comments%2Freply.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1301850%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExtensibility%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1303700%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20do%20Like%2FUnlike%20of%20Comments%20in%20SharePoint%20Modern%20Page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1303700%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F407701%22%20target%3D%22_blank%22%3E%40kalpeshvaghela%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20use%20the%20PnPJS%20library%20to%20like%2Fcomment%20a%20page%20comment%2C%20too.%20Check%20out%20the%20documentation%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fpnpjs%2Fsp%2Fcomments-likes%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%2C%20after%20you%20have%20the%20comment%20ID%2C%20you%20can%20make%20these%20call%20to%20like%2Fadd%20a%20comment%20to%20an%20already%20existing%20comment.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%20%20%20%20%20%20sp.web.lists.getByTitle(listID).items.getById(pageId).comments.getById(commentId).like()%3B%0A%20%20%20%20%20%20sp.web.lists.getByTitle(listID).items.getById(pageId).comments.getById(commentId).replies.add('here%20is%20some%20text')%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20worth%20noting%20that%20you%20can't%20add%20a%20reply%20to%20a%20reply%2C%20though.%20Hope%20this%20helps!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

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.

1 Reply
Highlighted

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.