function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
D_M_CD_M_C 

Cannot insert FeedItem to a Chatter Group

I am using Java with the SOAP api to transfer Chatter records.  I cannot post messages to existing Chatter groups.

 

The code below is simple Java code that tries to create a new FeedItem, add it to a group and insert the record.  I have confirmed that the userID is correct, the groupId is correct AND the user belongs to the group.  The user account I am using to do the transfer has the "Manage Chatter Messages" enabled.  I am using API v 25.

 

Why is my attempt to post to a group failing?

 

The error message I get is: The Insert failed because: insufficient access rights on cross-reference id

 

		String userID = "005E0000001JywAIAS";
		String groupId = "0F9E0000000Tp2mKAC";
		FeedItem newFeed = new FeedItem();
		Calendar greg = Calendar.getInstance();
		greg.add(Calendar.HOUR, -48);
		
		//newFeed.setId(feed.getId());
		newFeed.setBody("Faked ITEM GROUP test");
		newFeed.setParentId(groupId);
		newFeed.setCreatedDate(greg);
		newFeed.setCreatedById(userID);
		
		List<FeedItem> list = new ArrayList<FeedItem>();
		list.add(newFeed);
		loginCentral();
		SObject[] objs = new SObject[1];
		objs[0]=newFeed;
		uploadRecords(objs);

		logout();

 

Best Answer chosen by Admin (Salesforce Developers) 
Jia HuJia Hu
Your User must be the member of this Group first.

All Answers

Jia HuJia Hu
Your User must be the member of this Group first.
This was selected as the best answer
Haris Osmanagic, B&HHaris Osmanagic, B&H
@Jia Hu:

Even when the user is part of the group, the above code doesn't create a new feed item. I was using the following:
 
String userID = "user id";
String groupId = "group id";
FeedItem newFeed = new FeedItem();
Calendar greg = Calendar.getInstance();
greg.add(Calendar.HOUR, -48);

// newFeed.setId(feed.getId());
newFeed.setBody("Faked ITEM GROUP test");
newFeed.setParentId(groupId);
newFeed.setCreatedDate(greg);
newFeed.setCreatedById(userID);
com.sforce.soap.enterprise.sobject.SObject[] objects = { newFeed };
SaveResult res = eConn().create(objects)[0];
System.out.println(Arrays.toString(res.getErrors()));