Beanstalk

Code Review Comment Resource

This resource represents Comments from Code Review’s Discussion sub-page. Any user with at least read access to a repository can post a comment to any Code Review. Comments can be made on lines of code or on the Code Review as a whole. This API doesn’t support commenting on lines of code.

New format

We are gradually phasing out XML support from our API and this is one of the first resources that are provided only in JSON format. The format was also a bit adjusted compared to other resources: associated objects (like repositories and users) are now embedded into JSON itself, and there are no JSON root elements anymore.

Readable attributes

id integer Comment ID.
body string Comment text (Markdown source.)
rendered_body string Comment text (HTML.)
line_num integer Line number if comment was made for a line of code. For comments made on diff pieces this will be right line number.
line_num_left integer Left line number. For comments created on diff pieces.
file_path string File path for which comment was created
line_contents string For comments created on lines of code only. Contains contents of the line on which the comment was made.
revision string Revision number (or SHA1 hash) of the associated commit.
outdated boolean True of comment was made on a line of code that was changed since.
created_at datetime Date and time when the comment was created.
updated_at datetime Date and time when the comment was last updated.
author hash Comment author.
id integer User ID.
name string User full name.
login string User login.
email string User email address.

Writable attributes

body string Comment text with Markdown formatting.

Find All Comments for Code Review

json http-request
GET /api/{REPOSITORY_ID}/code_reviews/{REVIEW_ID}/comments.json

Click to expand…

json http-response
{
  "page": 1,
  "per_page": 25,
  "total_pages": 1,
  "page_entries": 4,
  "total_entries": 4,
  "comments": [
    {
      "id": 1,
      "body": "test",
      "rendered_body": "<p>test</p>\n",
      "line_num": null,
      "line_num_left": null,
      "file_path": null,
      "line_contents": null,
      "revision": null,
      "outdated": null,
      "created_at": "2014/12/29 21:04:18 -0500",
      "updated_at": "2014/12/29 21:04:18 -0500",
      "author": {
        "id": 1,
        "name": "Ilya Sabanin",
        "login": "ilya",
        "email": "ilya@example.com"
      }
    }
  ]
}

Find Comment by ID

json http-request
GET /api/{REPOSITORY_ID}/code_reviews/{REVIEW_ID}/comments/{COMMENT_ID}.json

Click to expand…

json http-response
{
  "id": 3,
  "body": "test",
  "rendered_body": "<p>test</p>\n",
  "line_num": null,
  "line_num_left": null,
  "file_path": null,
  "line_contents": null,
  "revision": null,
  "outdated": null,
  "created_at": "2014/12/29 21:04:21 -0500",
  "updated_at": "2014/12/29 21:04:21 -0500",
  "author": {
    "id": 1,
    "name": "Ilya Sabanin",
    "login": "ilya",
    "email": "ilya@example.com"
  }
}

Add Comment to Code Review

Comments created with this method will appear on Discussion sub-page of the Code Review. An Event will be created automatically for your Comment and an email notification will be sent to all Watchers.

json http-request
POST /api/{REPOSITORY_ID}/code_reviews/{REVIEW_ID}/comments.json

{
  "comment": {
    "body": "Test"
  }
}

Click to expand…

json http-response
STATUS: 201

{
  "id": 7,
  "body": "Test",
  "rendered_body": "<p>Test</p>\n",
  "line_num": null,
  "line_num_left": null,
  "file_path": null,
  "line_contents": null,
  "revision": null,
  "outdated": null,
  "created_at": "2014/12/31 09:47:03 -0500",
  "updated_at": "2014/12/31 09:47:03 -0500",
  "author": {
    "id": 1,
    "name": "Ilya Sabanin",
    "login": "ilya",
    "email": "ilya@example.com"
  }
}