+ Start a Discussion

How to post to a certain group via API

Hi all,


This is probably quite simple, but I haven't found any sample code anywhere, yet: How can I post to a certain from using the Chatter API?

The background is that a user wants to batch-post the same item to several groups in one go, so I want to built a little utility app that grabs the latest post by that user and copies it to several groups.

Any ideas?


Kind regards,




Jon Mountjoy_Jon Mountjoy_

Have you checked out the Chatter Resource Page, and in particular the Chatter Code Recipes article?  Check out Recipe 6, an in particular this comment "Similarly, you can post to a user or group feed by setting the parentId to the respective User/Group Id."


That should do it!


Thanks a lot, Jon. I should have been a bit more specific: I was looking for code examples using a Java client connecting to the SOAP API. The examples in the recipe and also on the cheat sheet are all written in Apex.

There is some Java sample code in the workbook ( http://www.salesforce.com/us/developer/docs/workbook_chatter/index.htm ), but it doesn't cover updating a group status.






Working with Chatter from something like Java is basically working with the Data Model. You just need to create a feeditem with the parentid being that of the groupid something like:



    SObject so = new SObject();
    so.setField("ParentId", "my-group-id"); 
    so.setField("Body", "hello there");




May be following link can give more code sample: