Obtaining the Changes of an MR
Function
Obtain the changes of an MR.
URI
GET /v2/repositories/{repository_id}/merge-requests/{merge_request_iid}/changes
Parameter | Mandatory | Type | Description |
|---|---|---|---|
repository_id | Yes | String | Repository short ID. |
merge_request_iid | Yes | Integer | Repository IID of the MR. |
Request Parameters
Parameter | Mandatory | Type | Description |
|---|---|---|---|
X-Auth-Token | Yes | String | User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
file_path | No | String | File path. |
ignore_whitespace_change | No | Boolean | Whether to ignore spaces. |
force_encode | No | Boolean | Whether to require transcoding. |
view | No | String | View (optional value: simple) |
commit_id | No | String | Commit ID. |
Response Parameters
Status code: 200
Parameter | Type | Description |
|---|---|---|
result | Result object | Response result. |
status | String | Response status. |
Status code: 400
Parameter | Type | Description |
|---|---|---|
error | Error object | Response error. |
status | String | Response status. |
Parameter | Type | Description |
|---|---|---|
id | Integer | MR ID. |
iid | Integer | MR IID. |
project_id | Integer | Repository ID. |
title | String | Title. |
description | String | Description |
state | String | MR status. |
created_at | String | Creation time. |
updated_at | String | Update time. |
target_branch | String | Target branch. |
source_branch | String | Source branch. |
user_notes_count | Integer | Number of reviews. |
upvotes | Integer | Added scores. |
downvotes | Integer | Reduced scores. |
author | UserDto object | Author. |
source_project_id | Integer | Source repository ID. |
target_project_id | Integer | Target repository ID. |
labels | Array of strings | Tag. |
work_in_progress | Boolean | WIP or not. |
merge_when_pipeline_succeeds | Boolean | Whether to automatically merge the request when the pipeline is successful. |
merge_status | String | Merge status. |
sha | String | sha |
should_remove_source_branch | Boolean | Whether to delete the source branch. |
force_remove_source_branch | Boolean | Whether to delete the source branch. |
web_url | String | Web page links. |
time_stats | TimeStats object | Time required. |
squash | Boolean | Whether it is a squash. |
merge_request_type | String | MR type. |
subscribed | Boolean | Whether to subscribe to the data. |
changes_count | String | Changed quantity. |
diff_refs | DiffRefs object | SHA value. |
user | User object | Users. |
added_lines | Integer | Added lines. |
removed_lines | Integer | Reduced lines. |
changes | Array of Changes | Changed files. |
Parameter | Type | Description |
|---|---|---|
id | Double | User ID. |
name | String | Username. |
state | String | User status. |
username | String | User IamId. |
name_cn | String | Name in Chinese. |
Parameter | Type | Description |
|---|---|---|
base_sha | String | Basic SHA. |
head_sha | String | Target SHA. |
start_sha | String | Source SHA. |
Parameter | Type | Description |
|---|---|---|
new_path | String | New path. |
old_path | String | Original path. |
a_mode | String | Mode a. |
b_mode | String | Mode b. |
file_path | String | File path. |
new_file | Boolean | Whether to add a file. |
renamed_file | Boolean | Whether to rename a file. |
deleted_file | Boolean | Whether to delete a file. |
diff | String | Difference. |
binary | Boolean | Whether a file is binary. |
too_large | Boolean | Whether the file is oversized. |
collapsed | Boolean | Whether to compress. |
added_lines | Integer | Added lines. |
removed_lines | Integer | Reduced lines. |
content_sha | String | SHA value of the content. |
submodule | Boolean | Sub-module or not. |
expanded | Boolean | Expand or not. |
diff_refs | DiffRefs object | SHA value. |
mode_changed | Boolean | Whether to change the mode. |
file_type | String | File type. |
Example Requests
GET https://{endpoint}/v2/repositories/456156/merge-requests/1/changes?view=simple Example Responses
Status code: 200
{
"result": {
"id": 42466,
"iid": 2,
"project_id": 892155,
"title": "Create a file 111",
"description": "merge \"1\" into \"master\"\nCreate a file 111",
"state": "opened",
"created_at": "2024-03-24T11:29:56.000+08:00",
"updated_at": "2024-04-10T17:34:06.000+08:00",
"target_branch": "master",
"source_branch": "1",
"user_notes_count": 2,
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 6916,
"name": "Online_L0_CodeHub",
"username": "5cb39fe67a2b465283c1463a87274980",
"state": "active",
"name_cn": "Online_L0_CodeHub"
},
"source_project_id": 892155,
"target_project_id": 892155,
"labels": [],
"work_in_progress": false,
"merge_when_pipeline_succeeds": false,
"merge_status": "can_be_merged",
"sha": "43b573473948e13934379993943ac5deea7cd391",
"should_remove_source_branch": false,
"force_remove_source_branch": false,
"web_url": "https://test.com/dcf7e8cde4474a4e8219921f564c32d6/test_no_readme/merge_requests/2",
"time_stats": {
"total_time_spent": 0
},
"squash": false,
"merge_request_type": "MergeRequest",
"subscribed": true,
"changes_count": "1",
"diff_refs": {
"base_sha": "ca4cf1a049e286032b25e1604f44f2969818b3f5",
"head_sha": "43b573473948e13934379993943ac5deea7cd391",
"start_sha": "ca4cf1a049e286032b25e1604f44f2969818b3f5"
},
"user": {
"can_merge": true
},
"added_lines": 5,
"removed_lines": 0,
"changes": [
{
"old_path": "111",
"new_path": "111",
"a_mode": "0",
"b_mode": "100644",
"file_path": "111",
"new_file": true,
"renamed_file": false,
"deleted_file": false,
"diff": "@@ -0,0 +1,5 @@\n+1\r\n+2\r\n+3\r\n+4\r\n+5\n\\ No newline at end of file\n",
"binary": false,
"too_large": false,
"collapsed": false,
"added_lines": 5,
"removed_lines": 0,
"content_sha": "43b573473948e13934379993943ac5deea7cd391",
"submodule": false,
"expanded": true,
"diff_refs": {
"base_sha": "ca4cf1a049e286032b25e1604f44f2969818b3f5",
"head_sha": "43b573473948e13934379993943ac5deea7cd391",
"start_sha": "ca4cf1a049e286032b25e1604f44f2969818b3f5"
},
"mode_changed": true,
"file_type": "text_type"
}
]
},
"status": "success"
}
Status code: 400
Bad Request
{
"error": {
"code": "CH.010001",
"message": "Invalid parameter"
},
"status": "failed"
} Status Code
Status Code | Description |
|---|---|
200 | OK |
400 | Bad Request |
Error code.
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.

