Create Comment
Create Comment
To create a comment, call the POST /comments API with the
message of the comment, as well as the ID of the file to leave the comment on.
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
}
}'await client.comments.createComment({
message: message,
item: {
id: fileId,
type: 'file' as CreateCommentRequestBodyItemTypeField,
} satisfies CreateCommentRequestBodyItemField,
} satisfies CreateCommentRequestBody);client.comments.create_comment(
message, CreateCommentItem(id=file_id, type=CreateCommentItemTypeField.FILE)
)await client.Comments.CreateCommentAsync(requestBody: new CreateCommentRequestBody(message: message, item: new CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.File)));try await client.comments.createComment(requestBody: CreateCommentRequestBody(message: message, item: CreateCommentRequestBodyItemField(id: fileId, type: CreateCommentRequestBodyItemTypeField.file)))client.getComments().createComment(new CreateCommentRequestBody(message, new CreateCommentRequestBodyItemField(fileId, CreateCommentRequestBodyItemTypeField.FILE)))BoxFile file = new BoxFile(api, "id");
file.addComment("This file is pretty cool.");comment = client.file(file_id='11111').add_comment('When should I have this done by?')var requestParams = new BoxCommentRequest()
{
Item = new BoxRequestEntity()
{
Type = BoxType.File,
Id = "12345"
},
Message = "Great work!"
};
BoxComment comment = await client.CommentsManager.AddCommentAsync(requestParams);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' }
*/
});A comment's message can also mentions users using the @ sign. To do so, add
the string @[userid:name] anywhere within the message. The user_id is the
target user's ID, where the name can be any custom phrase. In the Box UI this
name will link to the user's profile.
Then, pass this string as the tagged_message instead of the message.