Beanstalk

Comment Resource

Every Changeset in Beanstalk can have many Comments. The API allows you to view and create them.

Readable attributes

id integer Unique UD of Comment.
account_id integer ID of the associated Account.
repository_id integer ID of the associated Repository.
author_id integer ID of the User who created the Comment.
author_name string Full name of the User who created the comment.
author_email string Email address of the User who created the comment.
author_login string Username of the User who created the comment.
revision string Revision number (or hash ID) of the commit for which Comment was created.
file_path string Path of the file for which Comment was created (one of the commit’s changed files).
line_number integer Line number of the file for which Comment was created.
body string Contents of the Comment.
rendered_body string Contents of the Comment with Textile and HTML rendering applied. Generated automatically.
updated_at datetime Time when the Comment was las updated.
created_at datetime Time when the Comment was first added to the system.

Writable attributes

revision string Required.
file_path string Optional.
line_number integer Optional.
body string Required.

Note on formatting

Beanstalk will automatically escape all HTML tags from the body attribute, apply Textile formatting and turn all URls into clickable HTML links.

Find All Comments for Repository

Optional GET parameters:

  • page (integer) — page number for pagination;
  • per_page (integer) — number of elements per page (default 15, maximum 50).
json http-request
GET /api/{REPOSITORY_ID}/comments.json

Click to expand…

json http-response
[{
  "comment": { 
    "file_path": "",
    "created_at": "2011/10/05 13:10:00 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:00 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 2,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
},{
  "comment": {
    "file_path": "",
    "created_at": "2011/10/05 13:10:09 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:09 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 3,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
}]
xml http-request
GET /api/{REPOSITORY_ID}/comments.xml

Click to expand…

xml http-response
<?xml version="1.0" encoding="UTF-8"?>
<comments type="array">
  <comment>
    <id type="integer">324934</id>
    <account-id type="integer">4</account-id>
    <author-id type="integer">17</author-id>
    <author-name>John Doe</author-id>
    <author-login>ilya-sabanin</author-login>
    <author-email>ilya@example.com</author-email>
    <body>
      Hey, this is my first comment.
      I think you have a typo on this line.
    </body>
    <created-at type="datetime">2010-01-18T15:47:45Z</created-at>
    <file-path>trunk/index.html</file-path>
    <line-number>34</line-number>
    <rendered-body>
      &lt;p&gt;Hey, this is my first comment.
      I think you have a typo on this line.&lt;/p&gt;
    </rendered-body>
    <repository-id type="integer">2</repository-id>
    <revision type="integer">1</revision>
    <updated-at type="datetime">2010-01-18T15:47:45Z</updated-at>
  </comment>
  <comment>
    <id type="integer">834234</id>
    <account-id type="integer">4</account-id>
    <author-id type="integer">17</author-id>
    <author-name>John Doe</author-id>
    <author-login>ilya-sabanin</author-login>
    <author-email>ilya@example.com</author-email>
    <body>Check out my *textile* dude.</body>
    <created-at type="datetime">2010-01-18T15:48:54Z</created-at>
    <file-path nil="true"></file-path>
    <line-number nil="true"></line-number>
    <rendered-body>
      &lt;p&gt;Check out my <strong>textile</strong> dude.&lt;/p&gt;
    </rendered-body>
    <repository-id type="integer">2</repository-id>
    <revision type="integer">66</revision>
    <updated-at type="datetime">2010-01-18T15:48:54Z</updated-at>
  </comment>
</comments>

Find All Comments for Changeset

Optional GET parameters:

  • page (integer) — page number for pagination;
  • per_page (integer) — number of elements per page (default 15, maximum 50).
json http-request
GET /api/{REPOSITORY_ID}/comments.json?revision={REVISION}

Click to expand…

json http-response
[{
  "comment": { 
    "file_path": "",
    "created_at": "2011/10/05 13:10:00 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:00 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 2,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
},{
  "comment": {
    "file_path": "",
    "created_at": "2011/10/05 13:10:09 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:09 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 3,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
}]
xml http-request
GET /api/{REPOSITORY_ID}/comments.xml?revision={REVISION}

Click to expand…

xml http-response
<?xml version="1.0" encoding="UTF-8"?>
<comments type="array">
  <comment>
    <id type="integer">583197</id>
    <account-id type="integer">4</account-id>
    <author-id type="integer">17</author-id>
    <author-name>John Doe</author-id>
    <author-login>ilya-sabanin</author-login>
    <author-email>ilya@example.com</author-email>
    <body>
      Hey, this is my first comment.
      I think you have a typo on this line.
    </body>
    <created-at type="datetime">2010-01-18T15:47:45Z</created-at>
    <file-path>trunk/index.html</file-path>
    <line-number>34</line-number>
    <rendered-body>
      &lt;p&gt;Hey, this is my first comment.
      I think you have a typo on this line.&lt;/p&gt;
    </rendered-body>
    <repository-id type="integer">2</repository-id>
    <revision type="integer">1</revision>
    <updated-at type="datetime">2010-01-18T15:47:45Z</updated-at>
  </comment>
</comments>

Find All Comments for User

Returns an array of comments by a specific user across all repositories.

Admins can use user_id parameter to specify ID of any user from the account. Regular users can use method without user_id to receive their comments only.

Optional GET parameters:

  • page (integer) — page number for pagination;
  • per_page (integer) — number of elements per page (default 15, maximum 50).
json http-request
GET /api/comments/user.json?user_id={USER_ID}

Click to expand…

json http-response
[{
  "comment": { 
    "file_path": "",
    "created_at": "2011/10/05 13:10:00 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:00 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 2,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
},{
  "comment": {
    "file_path": "",
    "created_at": "2011/10/05 13:10:09 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:09 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 3,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
}]
xml http-request
GET /api/comments/user.xml?user_id={USER_ID}

Click to expand…

xml http-response
<?xml version="1.0" encoding="UTF-8"?>
<comments type="array">
  <comment>
    <id type="integer">583197</id>
    <account-id type="integer">4</account-id>
    <author-id type="integer">345661</author-id>
    <author-name>John Doe</author-id>
    <author-login>ilya-sabanin</author-login>
    <author-email>ilya@example.com</author-email>
    <body>
      Hey, this is my first comment.
      I think you have a typo on this line.
    </body>
    <created-at type="datetime">2010-01-18T15:47:45Z</created-at>
    <file-path>trunk/index.html</file-path>
    <line-number>34</line-number>
    <rendered-body>
      &lt;p&gt;Hey, this is my first comment.
      I think you have a typo on this line.&lt;/p&gt;
    </rendered-body>
    <repository-id type="integer">2</repository-id>
    <revision type="integer">1</revision>
    <updated-at type="datetime">2010-01-18T15:47:45Z</updated-at>
  </comment>
</comments>

Find Comment

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

Click to expand…

json http-response
"comment": {
  "file_path": "",
  "created_at": "2011/10/05 13:10:09 +0800",
  "author_login": "ilya",
  "body": "Shikaka",
  "author_name": "John Doe",
  "updated_at": "2011/10/05 13:10:09 +0800",
  "account_id": 2,
  "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
  "id": 3,
  "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
  "author_id": 2,
  "author_email": "ilya@example.com",
  "repository_id": 3,
  "line_number": ""
}
xml http-request
GET /api/{REPOSITORY_ID}/comments/{COMMENT_ID}.xml

Click to expand…

xml http-response
<?xml version="1.0" encoding="UTF-8"?>
<comment>
  <id type="integer">8543</id>
  <account-id type="integer">4</account-id>
  <author-id type="integer">17</author-id>
  <author-name>John Doe</author-id>
  <author-login>ilya-sabanin</author-login>
  <author-email>ilya@example.com</author-email>
  <body>Hey, this is my first comment.</body>
  <created-at type="datetime">2010-01-18T15:47:45Z</created-at>
  <file-path>trunk/index.html</file-path>
  <line-number>34</line-number>
  <rendered-body>
    &lt;p&gt;Hey, this is my first comment.&lt;/p&gt;
  </rendered-body>
  <repository-id type="integer">2</repository-id>
  <revision type="integer">1</revision>
  <updated-at type="datetime">2010-01-18T15:47:45Z</updated-at>
</comment>

Create Comment

json http-request
POST /api/{REPOSITORY_ID}/comments.json
{
  "comment": {
    "body": "Shikaka 2",
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d"
  }
}

Click to expand…

json http-response
{
  "comment": {
    "file_path": "",
    "created_at": "2011/10/05 13:10:09 +0800",
    "author_login": "ilya",
    "body": "Shikaka",
    "author_name": "John Doe",
    "updated_at": "2011/10/05 13:10:09 +0800",
    "account_id": 2,
    "rendered_body": "\u003Cp\u003EShikaka\u003C/p\u003E",
    "id": 3,
    "revision": "7ada704eac04075f763f36190716e43381fc6e1d",
    "author_id": 2,
    "author_email": "ilya@example.com",
    "repository_id": 3,
    "line_number": ""
  }
}
xml http-request
POST /api/{REPOSITORY_ID}/comments.xml
<comment>
  <revision type="integer">6</revision>
  <body>This is my comment text.</body>
  <file-path>/branches/application/super_file.txt</file-path>
  <line-number>4</line-number>
</comment>

Click to expand…

xml http-response
<?xml version="1.0" encoding="UTF-8"?>
<comment>
  <id type="integer">98636</id>
  <account-id type="integer">4</account-id>
  <author-id type="integer">17</author-id>
  <author-name>John Doe</author-id>
  <author-login>ilya-sabanin</author-login>
  <author-email>ilya@example.com</author-email>
  <body>This is my comment text.</body>
  <created-at type="datetime">2010-01-18T15:47:45Z</created-at>
  <file-path>/branches/application/super_file.txt</file-path>
  <line-number>4</line-number>
  <rendered-body>
    &lt;p&gt;This is my comment text.&lt;/p&gt;
  </rendered-body>
  <repository-id type="integer">2</repository-id>
  <revision type="integer">6</revision>
  <updated-at type="datetime">2010-01-18T15:47:45Z</updated-at>
</comment>

--OR IF INVALID--

<?xml version="1.0" encoding="UTF-8"?>
<errors>
  <error>Body can't be blank</error>
</errors>