POST: Create a comment

To create a comment instance, perform a POST on the comment collection, passing a JSON string. When posting the comment, you assign the comment to an instance, such as a defect.

Even though a comment is a field of an entity, you create the comment and assign it to the entity. You do not create the entity and add a comment to it.

Bulk POSTs are not supported.

Example: POST request to add a comment to a defect with ID 1048

*** Request ***
POST .../api/shared_spaces/<shared_space_id>/workspaces/1002/comments
{
    "data": [  
    {  "author":
        {   "id":"1001",
             "type":"workspace_user"
        },
       "text":"my new comment",
       "owner_work_item":
       {
          "id":"1024",
          "type":"defect"
       }
   }
  ]
}
 
*** Response ***
{
  "total_count": 1,
  "data": [
    {
      "type": "comment",
      "creation_time": "2016-10-30T11:17:39Z",
      "version_stamp": 1,
      "author": {
        "type": "workspace_user",
        "full_name": "TheUser@TheCompany",
        "name": "TheUser@TheCompany",
        "id": "1001"
      },
      "id": "1001",
      "text": "<html><body>\nmy new comment\n</body></html>",
      "last_modified": "2016-10-30T11:17:39Z"
    }
  ],
  "exceeds_total_count": false
}

Tip: For performance optimization, when GETting entities, comments are not included in the response. To see a list of comment IDs and types, you have to explicitly request them using the fields clause.

GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/defects&fields=comments

Back to top

See also: