コメントを作成

post
https://api.box.com/2.0
/comments

ユーザーによるコメントを特定のファイルに追加するか、他のコメントへの返信として追加します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

クエリパラメータ

string arrayクエリ内省略可能
id,type,name

レスポンスに含める属性のコンマ区切りリスト。このパラメータを使用すると、標準のレスポンスには通常含まれないフィールドをリクエストできます。

このパラメータを指定すると、明示的に指定しない限り標準フィールドはレスポンスに含まれず、リクエストしたフィールドのほかには、Mini版の表示のフィールドしか返されないことに注意してください。

リクエスト本文

object本文内

コメントを追加する項目。

string本文内必須
"11446498"

項目のID

string本文内必須
"file"

このコメントが追加される項目の種類。

次の値のいずれか1つ: file,comment

string本文内必須
"Review completed!"

コメントのテキスト。

特定のユーザーをメンションするには、 代わりにtagged_messageパラメータを使用します。

string本文内省略可能
"@[1234:John] Review completed!"

メッセージ内のどこかで@[user_id:name]を使用して他のユーザーをメンションしているコメントのテキスト。メンションされたユーザーには、メンションされたことを知らせるメール通知が送信されます。

user_idはターゲットユーザーのIDで、nameには任意のカスタムフレーズを使用できます。Box UIでは、この名前がユーザーのプロフィールにリンクされます。

他のユーザーをメンションしていない場合は、代わりにmessageを使用します。

レスポンス

application/jsonコメント (Full)

新しく作成されたコメントオブジェクトを返します。

使用可能なすべてのフィールドがデフォルトで返されるとは限りません。特定のフィールドを明示的にリクエストするには、fieldsクエリパラメータを使用します。

予期しないクライアントエラー。

post
コメントを作成
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X POST "https://api.box.com/2.0/comments" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "message": "Review completed!",
       "item": {
         "type": "file",
         "id": 426436
       }
     }'
.NET
var requestParams = new BoxCommentRequest()
{
    Item = new BoxRequestEntity()
    {
        Type = BoxType.File,
        Id = "12345"
    },
    Message = "Great work!"
};
BoxComment comment = await client.CommentsManager.AddCommentAsync(requestParams);
Java
BoxFile file = new BoxFile(api, "id");
file.addComment("This file is pretty cool.");
Python
comment = client.file(file_id='11111').add_comment('When should I have this done by?')
Node
client.comments.create('33333', 'Is this the latest version?')
    .then(comment => {
        /* comment -> {
            type: 'comment',
            id: '11111',
            is_reply_comment: false,
            message: 'Is this the latest version?',
            created_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            created_at: '2012-12-12T11:25:01-08:00',
            item: { id: '33333', type: 'file' },
            modified_at: '2012-12-12T11:25:01-08:00' }
        */
    });
iOS
client.comments.create(
    itemId: "11111",
    itemType: "file",
    message: "Thanks!"
) { (result: Result<Comment, BoxSDKError>) in
    guard case let .success(comment) = result else {
        print("Error creating comment")
        return
    }

    print("Added comment to \(comment.item.name): \"\(comment.message)\"")
}

レスポンスの例

{
  "id": "11446498",
  "type": "comment",
  "created_at": "2012-12-12T10:53:43-08:00",
  "created_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "is_reply_comment": true,
  "item": {
    "id": "11446498",
    "type": "file"
  },
  "message": "@Aaron Levie these tigers are cool!",
  "modified_at": "2012-12-12T10:53:43-08:00",
  "tagged_message": "@[1234567:Aaron Levie] these tigers are cool!"
}