Box Developerドキュメント

Box Developerドキュメントの新しいベータ版サイトがまもなくリリースされる予定です。最新の開発者向けガイド、APIリファレンス、AI搭載の検索により、Boxを使用した迅速な開発をサポートします。更新情報については今しばらくお待ちください。

コメントの作成

ガイド コメント コメントの作成

コメントの作成

コメントを作成するには、コメントのメッセージと、コメントを残すファイルのIDを指定してPOST /comments 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
       }
     }'
Node/TypeScript v10
await client.comments.createComment({
  message: message,
  item: {
    id: fileId,
    type: 'file' as CreateCommentRequestBodyItemTypeField,
  } satisfies CreateCommentRequestBodyItemField,
} satisfies CreateCommentRequestBody);
Python v10
client.comments.create_comment(
    message, CreateCommentItem(id=file_id, type=CreateCommentItemTypeField.FILE)
)
.NET v10
await client.Comments.CreateCommentAsync(requestBody: new CreateCommentRequestBody(message: message, item: new CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.File)));
Swift v10
try await client.comments.createComment(requestBody: CreateCommentRequestBody(message: message, item: CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.file)))
Java v10
client.getComments().createComment(new CreateCommentRequestBody(message, new CreateCommentRequestBodyItemField(fileId, CreateCommentRequestBodyItemTypeField.FILE)))
.NET v6
await client.Comments.CreateCommentAsync(requestBody: new CreateCommentRequestBody(message: message, item: new CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.File)));
Node v4
await client.comments.createComment({
  message: message,
  item: {
    id: fileId,
    type: 'file' as CreateCommentRequestBodyItemTypeField,
  } satisfies CreateCommentRequestBodyItemField,
} satisfies CreateCommentRequestBody);

コメントのメッセージでは、@記号を使用してユーザーをメンションすることもできます。そのためには、メッセージ内の任意の場所に@[userid:name]という文字列を追加します。user_idはターゲットユーザーのIDで、nameには任意のカスタムフレーズを使用できます。Box UIでは、この名前がユーザーのプロフィールにリンクされます。

次に、この文字列をmessageではなくtagged_messageとして渡します。