1

I am getting an error when using the ConnectApi to post a feed:

ConnectApi.NotFoundException: Resource not found. Class.ConnectApi.ChatterFeeds.getFeedElement: line 1502, column Class.ChatterPostParser: line 154, column 1 Class.RestComments.insertComment: line 66, column 1

I am trying this code:

List<User> mentionUsers = new List<User>();
ConnectApi.CommentInput feedCommentInput = 

ChatterPostParser.parseChatterCommentWithMentions(comment, mentionUsers);
ConnectApi.Comment commentRep = ConnectApi.ChatterFeeds.postCommentToFeedElement(
                                  Network.getNetworkId(),
                                  (Id)feedId,
                                  feedCommentInput,
                                  null);
  • Can you please provide the code from which you are calling this code. I mean are you calling this code by a web-service ? – Tarachand Karwal Jul 14 '17 at 11:01
  • @TarachandKarwal I am calling this from REST API. – itzmukeshy7 Jul 14 '17 at 12:00
1

If you are calling it from Rest Api then Network.getNetworkId() will not work and you have to hard code the network Id. So place network Id instead of Network.getNetworkId() and it will work definitely.

  • 1
    Thanks it worked after hard coding the id, any workaround to make it dynamic? – itzmukeshy7 Jul 17 '17 at 3:18
  • Create a Custom Setting and store Id in it. So it's value will be org wise not will be static always. – Tarachand Karwal Jul 18 '17 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.