Obtaining the Merge Request File Change List
Function
This API is used to obtain the merge request file change list.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
GET https://{hostURL}/v4/repositories/{repository_id}/merge-requests/{merge_request_iid}/changes
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| repository_id | Yes | Integer | Definition You can query the project list to obtain the repository ID by calling the API used to query user's all repositories. Constraints N/A. Value range: 1~2147483647 |
| merge_request_iid | Yes | Integer | Definition MR internal ID (IID). Value range: 1~2147483647 |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token. Obtain a token by calling the IAM API for obtaining a user token. The value of X-Subject-Token in the response header is the user token. Constraints Mandatory. Range 1–100,000 characters. Default Value N/A. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| [items] | Array of SimpleMergeRequestChangesDto objects | MR file change list details |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | MR id |
| repository_id | Integer | Repository ID |
| title | String | MR title |
| description | String | MR description |
| state | String | MR status |
| source_branch | String | MR source branch name |
| target_branch | String | MR target branch name |
| author | UserBasicDto object | User information |
| web_url | String | MR URL |
| create_at | String | Time when an MR was created |
| update_at | String | Last update time of an MR |
| sha | String | Commit ID of the target version of the current change |
| change_count | Integer | Number of changed files |
| diff_refs | DiffRefDto object | MR change commit, including base_sha, start_sha, and head_sha |
| added_lines | Integer | New line |
| removed_lines | Integer | Deleted line |
| changes | Array of FileChangeDto objects | Change file details list |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Definition User ID. Value range: 1~2147483647 |
| name | String | Definition Username. |
| username | String | Definition Username. |
| state | String | Definition: User status Value range: Enumeration values: |
| service_license_status | Integer | Service-level permission status. 0: disabled; 1: enabled |
| avatar_url | String | User profile picture URL |
| avatar_path | String | User profile picture path |
| | String | User email |
| name_cn | String | Username (CN) |
| web_url | String | User homepage |
| nick_name | String | User alias |
| tenant_name | String | Tenant name |
| error_message | String | Definition When some query APIs detect that the user permission in the transfer parameter is insufficient or the user does not exist, the user is returned but the field is not empty for information. |
| Parameter | Type | Description |
|---|---|---|
| file_path | String | File path |
| old_path | String | Change file source branch path |
| new_path | String | Change file target branch path |
| a_mode | String | Old file permissions |
| b_mode | String | New file permissions |
| mode_changed | Boolean | Whether the file permission is changed |
| file_type | String | File type |
| new_file | Boolean | New file or not |
| renamed_file | Boolean | Renamed file or not |
| deleted_file | Boolean | Deleted file or not |
| diff | String | Change file content |
| binary | Boolean | Binary file or not |
| too_large | Boolean | Large file or not |
| collapsed | Boolean | Folded file or not |
| added_lines | Integer | New lines in a file |
| removed_lines | Integer | Lines deleted from the file |
| content_sha | String | Latest commit ID of the file |
| diff_refs | DiffRefDto object | MR change commit, including base_sha, start_sha, and head_sha |
| Parameter | Type | Description |
|---|---|---|
| base_sha | String | Commit ID of the common ancestor shared by target and source branches |
| head_sha | String | Latest commit ID of the source branch |
| start_sha | String | Latest commit ID of the target branch |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition Error code. |
| error_msg | String | Definition Error message. |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition Error code. |
| error_msg | String | Definition Error message. |
Example Requests
/v4/repositories/2111976239/merge-requests/6/changes
Example Responses
Status code: 200
OK
{
"id" : 61415,
"repository_id" : 2111784689,
"title" : "Update dev",
"description" : "merge \\\"dev\\\" into \\\"master\\\"\\nUpdate dev",
"state" : "opened",
"source_branch" : "dev",
"target_branch" : "master",
"author" : {
"id" : 10311,
"name" : "repo_xuxu",
"name_cn" : "repo_xuxu",
"nick_name" : "repo_xx",
"tenant_name" : "example_name",
"username" : "e2dd5152774149298b749e245523bc78",
"state" : "active",
"email" : "e2dd5152774149298b749e245523bc78@example.com",
"web_url" : "https://example.com/e2dd5152774149298b749e245523bc78"
},
"web_url" : "https://example.com/yx_test_repo_yangxu00001/author_approval_test/merge_requests/12",
"sha" : "7817fb2d9d65e64389ce4cebc542aa2948f45da5",
"change_count" : 1,
"diff_refs" : {
"base_sha" : "ee792e378901e39008c6cbdd5bf01b056ba56e9b",
"head_sha" : "7817fb2d9d65e64389ce4cebc542aa2948f45da5",
"start_sha" : "283ae4a61aefac2c6c559544ca2af6d1a85ee02b"
},
"added_lines" : null,
"removed_lines" : null,
"changes" : [ {
"file_path" : "dev",
"old_path" : "dev",
"new_path" : "dev",
"a_mode" : 33188,
"b_mode" : 33188,
"mode_changed" : false,
"file_type" : "text_type",
"new_file" : false,
"renamed_file" : false,
"deleted_file" : false,
"diff" : "@@ -1,3 +1,3 @@\\n-dev1111\\n+dev11112222222333\\n",
"binary" : false,
"too_large" : false,
"collapsed" : false,
"added_lines" : 1,
"removed_lines" : 1,
"content_sha" : "7817fb2d9d65e64389ce4cebc542aa2948f45da5",
"diff_refs" : {
"base_sha" : "ee792e378901e39008c6cbdd5bf01b056ba56e9b",
"head_sha" : "7817fb2d9d65e64389ce4cebc542aa2948f45da5",
"start_sha" : "283ae4a61aefac2c6c559544ca2af6d1a85ee02b"
}
} ],
"create_at" : "2025-02-18T15:20:50.000+08:00",
"update_at" : "2025-02-26T14:45:45.000+08:00"
} Status code: 400
Bad Request
{
"error_code" : "CH.00405011",
"error_msg" : "Request error."
} Status code: 401
Unauthorized
{
"error_code" : "DEV.00000003",
"error_msg" : "Authentication information expired."
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 401 | Unauthorized |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.