[SalesForce] Create chatter post with mention for API version 37.0

I want to create chatter post with mention for API version 37.0

Have a look over this link Chatter Api Saying

Feed item methods aren’t available in version 32.0. In version 32.0 and later, use feed element methods.

When using postFeedElement(communityId, feedElement, feedElementFileUpload) this method supported API Version is 31.0–35.0

In version 36.0 and later, this method is no longer available because you can’t create a feed post and upload a binary file in the same call. Upload files to Salesforce first, and then use postFeedElement(communityId, feedElement) to create the feed post and attach the files.

Then

How to create chatter post with mention for API version 37.0??

Best Answer

You can follow this example for posting a mention. However, the example pertains to older API versions. To use v37.0, you'll need to make a change to the last line. Instead of this:

ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput, null);

use this:

ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);
Related Topic