Feed Elements Capability, Comments Items
To upload a binary file to attach to a comment, you must send it in a multipart/form-data request. To send the text of the comment, you can choose to include a JSON or XML rich input body part in the multipart/form-data request. Alternately, you can choose to pass the information in request parameter parts. For information about how to create the multipart/form-data message, see Uploading Binary Files.
- Resource
-
/chatter/feed-elements/feedElementId/capabilities/comments/items
/connect/communities/communityId/chatter/feed-elements/feedElementId/capabilities/comments/items
- Available version
- 32.0
- Requires Chatter
- Yes
- HTTP methods
- GET, POST
- Request parameters for GET
-
Parameter Name Type Description Required or Optional Available Version page String The page token to use to view the page. Use the value given in the nextPageUrl property of the Comment Page. Optional 32.0 pageSize Integer The number of comments per page. The default value is 3. Optional 32.0 sort String Order of comments. Values are: - CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
- CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
- Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.
Optional 44.0 threadedCommentsCollapsed Boolean Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you don’t specify, the default is false. Optional 44.0 - Response body for GET
-
Comment Page
If the feed element doesn’t support this capability, the response is 404: Not Found.
- Request body for POST
-
- Root XML tag
- <comment>
- Properties
-
Name Type Description Required or Optional Available Version attachment Depends on type. Values are: Optional 24.0–31.0 body Message Body Input The body of the comment. Feed item and comment bodies have a 10,000 character limit. Because this limit can change, we recommend that clients make a describeSObjects() call on the FeedItem or FeedComment object. To determine the maximum number of allowed characters, look at the length of the Body or CommentBody field.
To edit this property in a comment, make a PATCH request to /chatter/comments/commentId. Editing comments is supported in version 34.0 and later.
Rich text and inline images are supported in comment bodies in version 35.0 and later. Entity links are supported in version 43.0 and later.
Required 23.0 capabilities Comment Capabilities Input Capabilities of the comment, such as a file attachment. You can edit a comment’s body, but you can’t update a comment’s capabilities.
Optional 32.0 threadParentId String ID of the parent comment for a threaded comment. Optional 44.0
- Request parameters for POST
-
Parameter Name Type Description Required or Optional Available Version text String The comment text. Required 32.0 - Response body for POST
-
Comment
If the feed element doesn’t support this capability, the response is 404: Not Found.
- Example for posting a comment using the request body
-
{ "body":{ "messageSegments":[ { "type":"Text", "text":"New comment" } ] } }
- Example for posting a comment with a mention using the request body
-
{ "body" : { "messageSegments" : [ { "type": "mention", "id" : "005D0000001GpHp" }, { "type": "text", "text" : " Did you see the new plans?" } ] } }
- Example for posting a comment with multiple mentions using the request body
-
{ "body" : { "messageSegments" : [ { "type": "mention", "id":"005D0000001LL8YIAW" }, { "type" : "Text", "text" : " " }, { "type": "mention", "id":"005D0000001LL8sIAG" }, { "type": "text", "text":" Did you see the new plans?" } ] } }
- Example for posting a comment with a file using the request body
-
{ "body":{ "messageSegments":[ { "type":"Text", "text":"Please take a look at this file." } ] }, "capabilities":{ "content":{ "contentDocumentId":"069D00000001pyS" } } }
- Example for posting a rich-text comment using the request body
-
{ "body":{ "messageSegments":[ { "markupType" : "Paragraph", "type" : "MarkupBegin" }, { "markupType" : "Bold", "type" : "MarkupBegin" }, { "text" : "First line of text.", "type" : "Text" }, { "markupType" : "Bold", "type" : "MarkupEnd" }, { "markupType" : "Paragraph", "type" : "MarkupEnd" }, { "markupType" : "Paragraph", "type" : "MarkupBegin" }, { "text" : " ", "type" : "Text" }, { "markupType" : "Paragraph", "type" : "MarkupEnd" }, { "markupType" : "Paragraph", "type" : "MarkupBegin" }, { "text" : "Second line of text.", "type" : "Text" }, { "markupType" : "Paragraph", "type" : "MarkupEnd" } ] } }
- Example for posting a comment with a code block using the request body
-
{ "body":{ "messageSegments":[ { "markupType" : "Code", "type" : "MarkupBegin" }, { "text" : "<script>var i, t = 0;\nfor (i = 0; i < 5; i++) {\n t += i;\n}\n</script>", "type" : "Text" }, { "markupType" : "Code", "type" : "MarkupEnd" } ] } }
- Example for posting a comment with an inline image using the request body
-
{ "body":{ "messageSegments":[ { "type":"Text", "text":"Please take a look at this file." }, { "type":"InlineImage", "fileId":"069xx00000000QO", "altText":"API Spec" }, { "type":"Text", "text":"And this one." }, { "type":"InlineImage", "fileId":"069xx00000000QT", "altText":"REST API Spec" } ] } }