Post a Feed Element and Include Files from Salesforce

Post a feed element with Salesforce files in Chatter.

This example posts a feed element with more than one file, all of which have been uploaded to Salesforce.

In version 36.0 and later, you can’t create a feed post and upload a binary file in the same request. Upload files to Salesforce first, and then use the file IDs to attach one or more files to a feed post.

Important

Resource
/chatter/feed-elements
HTTP method
POST
Request body
Feed Item Input

This Feed Item Input request body includes a body property that is a Message Body Input request body. In this example, the Message Body Input request body includes a messageSegments property that has one Message Segment Input: Text request body.

This Feed Item Input request body also includes a capabilities property that is a Feed Element Capabilities Input request body. In this example, the Feed Element Capabilities Input includes a files property that is a Files Capability Input request body. The Files Capability Input request body includes an items property that is a collection of File ID Input request bodies.

Request body example
{
   "body":{
      "messageSegments":[
         {
            "type":"Text",
            "text":"Please take a look at these files."
         }
      ]
   },
   "capabilities":{
      "files":{
         "items": [
            {"id": "069D00000001IOh"},
            {"id": "069D00000002IOg"}
         ]
      }
   },
   "subjectId":"me",
   "feedElementType":"FeedItem"
}
Returns
Feed Item