Post a Comment and Include a File from Salesforce

Post a comment with a Salesforce file in Chatter.

This example posts a comment with a file that has already been uploaded to Salesforce. To upload a new file, see Uploading Binary Files.

Resource
/chatter/feed-elements/feedElementId/capabilities/comments/items
HTTP method
POST
Request body
Comment Input

This Comment 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 Comment Input request body also includes a capabilities property that is a Comment Capabilities Input request body. In this example, the Comment Capabilities Input includes a content property that is a Content Capability Input request body.

Request parameter
text
Request body example
{
   "body":{
      "messageSegments":[
         {
            "type":"Text",
            "text":"Please take a look at this file."
         }
      ]
   },
   "capabilities":{
      "content":{
         "contentDocumentId":"069D00000001pyS"
      }
   }
}
Returns
Comment