I am using the following method to share a file to a group.
ConnectApi.FeedItem feadItem = ConnectApi.ChatterFeeds.postFeedItem(communityId, feedType, subjectId, input,filebody);
I want to add topic to the feed item.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
In order to add a topic to a feed item, you need to post the feed item first, and then call either ConnectApi.Topics.assignTopic() or ConnectApi.Topics.assignTopicByName(). It's not possible currently to assign the topic and post the feed item in a single call. See the documentation for the ConnectApi.Topics class for more info.