Newer Version Available

This content describes an older version of this product. View Latest

Post a Comment with a Code Block

This example posts a feed element that includes a code block.

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: Markup Begin request body, one Message Segment Input: Text request body, and one Message Segment Input: Markup End request body.

Request body example
1{
2   "body":{
3      "messageSegments":[
4         {
5            "markupType" : "Code",
6            "type" : "MarkupBegin"
7         },
8         {
9             "text" : "<script>var i, t = 0;\nfor (i = 0; i < 5; i++) {\n   t +=
10                       i;\n}\n</script>",
11             "type" : "Text"
12         },
13         {
14            "markupType" : "Code",
15            "type" : "MarkupEnd"
16         }
17      ]
18   }
19}
Returns
Comment