CreateComment
Creates a comment on a merge request. You can create global comments and inline comments. The comment nesting level generally does not exceed three levels.
Try it now
Test
RAM authorization
Request syntax
POST /api/v4/projects/code_reviews/comments/create_comment HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| organizationId |
string |
Yes |
The enterprise identifier, also known as the enterprise ID. This is a string that can be obtained from the Yunxiao URL, such as https://devops.aliyun.com/organization/[OrganizationId]. |
5ebbc0228123212b59xxxxx |
| accessToken |
string |
No |
The personal access token. This field is not required if you use an Alibaba Cloud AccessKey ID and AccessKey secret or Security Token Service (STS) temporary authorization. |
f0b1e61db5961df5975a93f9129d2513 |
| repositoryIdentity |
string |
Yes |
The ID or full path of the code repository. |
2835387 or codeup/codeup-demo |
| localId |
integer |
Yes |
The local ID of the merge request, which indicates the sequence number of the merge request in the code repository. |
1 |
| body |
object |
No |
The request body. |
|
| content |
string |
Yes |
The content of the comment. |
Comment content |
| commentType |
string |
Yes |
The comment type. Valid values:
|
GLOBAL_COMMENT |
| parentCommentBizId |
string |
No |
The business ID of the parent comment. |
2666ac1ac53841b0ba1b042e383279cc |
| resolved |
boolean |
No |
Specifies whether the comment is resolved. Important If the business ID of the parent comment is empty, meaning a root comment is being created, you must set the value of resolved. |
false |
| filePath |
string |
No |
The file path. Note
This value is required only when commentType is set to INLINE_COMMENT. |
/src/main/test.java |
| lineNumber |
integer |
No |
The line number of the file where the comment is located. This parameter is available only for inline file comments. |
1 |
| patchSetBizId |
string |
No |
The ID of the associated merge request version. Important If you create a comment of the INLINE_COMMENT type, this value is required. |
b7d8386be17c4ca68a07140db4836257 |
| draft |
boolean |
No |
Specifies whether the comment is a draft. |
false |
| fromPachSetBizId |
string |
No |
The ID of the base version for comparison. Important If you create a comment of the INLINE_COMMENT type, this value is required. |
b7d8386be17c4ca68a07140db4836257 |
| toPatchSetBizId |
string |
No |
The ID of the target version for comparison. Important If you create a comment of the INLINE_COMMENT type, this value is required. |
543cd42cbfc0447b920a670e9897b6f7 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| requestId |
string |
The request ID. |
ASSDS-ASSASX-XSAXSA-XSAXSAXS |
| success |
boolean |
Indicates whether the call is successful. |
true |
| errorCode |
string |
The error code. |
Openapi.RequestError |
| errorMessage |
string |
The error message. |
"" |
| result |
object |
The returned result. |
|
| commentBizId |
string |
The unique business ID of the comment. |
5c399e3685e542a28db16d93e9f82abb |
| commentType |
string |
The comment type. Valid values:
|
GLOBAL_COMMENT |
| state |
string |
The comment state. Valid values:
|
OPENED |
| resolved |
boolean |
Indicates whether the comment is resolved. |
false |
| deleted |
boolean |
Indicates whether the comment is deleted. |
false |
| commentTime |
string |
The time when the comment was created. The format is YYYY-MM-DD HH:mm:ss. |
2022-03-18 14:24:54 |
| lastEditTime |
string |
The time when the comment was last edited. The format is YYYY-MM-DD HH:mm:ss. |
2022-03-18 14:24:54 |
| content |
string |
The content of the comment. |
This logic has been reviewed. Consider adding boundary condition tests |
| author |
object |
The information about the commenter. |
|
| aliyunPk |
string |
The Alibaba Cloud account ID. |
123456789012**** |
| name |
string |
The username. |
test-codeup |
| username |
string |
The user logon name. |
test-codeup |
| state |
string |
The user state. Valid values:
|
active |
| avatarUrl |
string |
The URL of the avatar. |
Avatar URL https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
|
string |
The email address of the user. |
username@example.com |
|
| id |
integer |
The primary key ID, which has no business meaning. |
19927 |
| relatedPatchSet |
object |
The information about the associated version. |
|
| patchSetNo |
string |
The version number. |
1 |
| patchSetBizId |
string |
The unique business ID of the version. |
513fcfd81a9142d2bb0db4f72c0aa15b |
| patchSetName |
string |
The version name. |
Version 1 |
| commitId |
string |
The commit ID associated with the version. |
1a072f5367c21f9de3464b8c0ee8546e47764d2d |
| shortId |
string |
The short commit ID. |
1a072f53 |
| relatedMergeItemType |
string |
The associated merge type. Valid values:
|
MERGE_SOURCE |
| createdAt |
string |
The creation time. The format is YYYY-MM-DD HH:mm:ss. |
2022-03-18 14:24:54 |
| lineNumber |
string |
The line number of the file where the comment is located. This parameter is available only for inline file comments. |
3 |
| filePath |
string |
The file path. This parameter is available only when commentType is set to INLINE_COMMENT. |
src/main/update.txt |
| parentCommentBizId |
string |
The business ID of the parent comment. |
4c5dcec6a8dc41e69c369737dadc1841 |
| rootCommentBizId |
string |
The business ID of the root comment. |
dcf2b23cebfc418f98dbd35e423d9fd3 |
Examples
Success response
JSON format
{
"requestId": "ASSDS-ASSASX-XSAXSA-XSAXSAXS\n",
"success": true,
"errorCode": "Openapi.RequestError",
"errorMessage": "\"\"",
"result": {
"commentBizId": "5c399e3685e542a28db16d93e9f82abb",
"commentType": "GLOBAL_COMMENT",
"state": "OPENED",
"resolved": false,
"deleted": false,
"commentTime": "2022-03-18 14:24:54\n",
"lastEditTime": "2022-03-18 14:24:54\n",
"content": "xxxx",
"author": {
"aliyunPk": "xxx",
"name": "test-codeup",
"username": "test-codeup",
"state": "active",
"avatarUrl": "Avatar URL\n\nhttps://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100",
"email": "username@example.com",
"id": 19927
},
"relatedPatchSet": {
"patchSetNo": "1",
"patchSetBizId": "513fcfd81a9142d2bb0db4f72c0aa15b",
"patchSetName": "Version 1",
"commitId": "1a072f5367c21f9de3464b8c0ee8546e47764d2d",
"shortId": "1a072f53",
"relatedMergeItemType": "MERGE_SOURCE",
"createdAt": "2022-03-18 14:24:54\n"
},
"lineNumber": "3",
"filePath": "src/main/update.txt",
"parentCommentBizId": "4c5dcec6a8dc41e69c369737dadc1841",
"rootCommentBizId": "dcf2b23cebfc418f98dbd35e423d9fd3"
}
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.