I am trying to use the Chatter rest API to get the comments of a FeedItem from the chatter feed. It all appears to be working OK except there appears to be a limitation on the amount of comments I get back.

For example I have a feed item that has 5 comments but with my code built following the Chatter Rest API documentation I only ever get 3 comments back. I can't seem to get the API to ever return all the comments, it only ever returns the last 3 comments.

My code is as follows:

//APEX Class

public ConnectApi.FeedItemPage feedItemPage{get;set;}
feedItemPage = ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null, ConnectApi.FeedType.Record, testID);

//APEX Page

<apex:repeat value="{!feedItemPage.items}" var="feedItem">
      <apex:repeat value="{!feedItem.comments.comments}" var="comment">
             <apex:repeat value="{!comment.body.messageSegments}" var="segment">

And I coded it following the API here:


Is the fact that it is only ever returning the last 3 comments some form of limitation or is there something wrong in my code?


There's a different method that you can use to control the number of comments that get returned. The parameter is called recentCommentCount.

Instead of using this method:

ConnectApi.ChatterFeeds.getFeedItemsFromFeed(String communityId, ConnectApi.FeedType feedType, String subjectId)

Use this one:

ConnectApi.ChatterFeeds.getFeedItemsFromFeed(String communityId, ConnectApi.FeedType feedType, String subjectId, Integer recentCommentCount, ConnectApi.FeedDensity density, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)

Here's a link to the documentation that describes all of the parameters.

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.