[SalesForce] Post a feed in Community Chatter Group

I have a private chatter group in community. I want to post something in this group by System Admin.

When system admin create a FeedItem and putting ParentId = groupId programatically then getting following Exception :

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access
rights on cross-reference id:

I have also changes the Group Access as public or Unlisted, but error remain the same.
Please help me for the same.
Follwing is code :

FeedItem feed = new FeedItem();

feed.Body = 'Hello from Admin';

feed.ParentId = '0F9M00000009V7v'; // Community's Chatter Group ID 

feed.visibility = 'AllUsers';

insert feed;

Best Answer

I have fixed this issue. I have passed Network scope id.

feed.ParentId = ''; // Community's Chatter Group ID

feed.NetworkScope= ''; // ID of community (network)

Related Topic