Importing a Merge Request
Function
This API is used to import a merge request.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
POST https://{hostURL}/v4/repositories/{repository_id}/import-merge-requests
| 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 |
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. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| iid | Yes | Integer | MR IID Value range: 1~9223372036854775807 |
| source_uniq_key | Yes | String | Import the unique identifier |
| author_id | No | Integer | Author ID Value range: 1~9223372036854775807 |
| state | Yes | String | Status Enumeration values: |
| title | No | String | Title |
| description | No | String | Description. |
| source_branch | Yes | String | Source branch |
| target_branch | Yes | String | Target branch |
| target_repository_id | Yes | String | Target repository |
| labels | No | Object | Label |
| created_at | No | String | Creation time |
| updated_at | No | String | Update time. |
| merged_at | No | String | Merge time |
| closed_at | No | String | Close time |
| approvers | No | Array of ApproverParamDto objects | Approver list |
| diff_refs | Yes | Object | MR change commit list |
| squash | No | Boolean | Squash merge |
| remove_source_branch | No | Boolean | Delete the source branch after MR merge |
| branch_is_deleted | No | Boolean | Whether the source branch is deleted |
| fork | No | Boolean | Whether the source MR is a fork MR |
| import_source_from | No | String | Import source |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| approver_id | No | Integer | Approver ID |
| code_owner | No | Boolean | Code owner |
| accept | No | Boolean | Accepted or not |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| base_sha | Yes | String | Common reference point of the source branch and target branch in an MR |
| start_sha | Yes | String | In an MR, the first commit point in the direction starting from the common reference point to the source branch. |
| head_sha | Yes | String | Commit point to which the source branch directs in an MR |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| id | Integer | MR ID |
| iid | Integer | MR IID |
| repository_id | Integer | Target repository ID |
| title | String | MR title |
| description | String | MR description |
| state | String | MR status |
| created_at | String | Creation time |
| updated_at | String | Update time. |
| source_branch | String | Source branch |
| target_branch | String | Target branch |
| is_source_branch_protected | Boolean | Whether the source branch is a protected branch |
| devcloud_source_branch | String | Source branch |
| author | UserBasicExternalDto object | Author |
| source_repository_id | Integer | Source repository ID |
| target_repository_id | Integer | Target repository ID |
| source_project_id | String | Source project ID |
| target_project_id | String | Target project ID |
| labels | Array of objects | Label |
| work_in_progress | Boolean | Work in progress (WIP) |
| milestone | MilestoneBasicDto object | Milestone |
| merge_when_build_succeeds | Boolean | Automatically merged when the pipeline is successful |
| merge_status | String | Mergeable status |
| sha | String | Latest commit of the current MR |
| merge_commit_sha | String | Merge commit node |
| subscribed | Boolean | Subscription |
| merged_by | UserBasicExternalDto object | Merger |
| merged_at | String | Merge time |
| closed_by | UserBasicExternalDto object | Closer |
| closed_at | String | Close time |
| user_notes_count | Integer | Number of review comments |
| force_remove_source_branch | Boolean | Delete source branch after merge |
| web_url | String | Homepage URL |
| merge_request_diff | MergeRequestDiffExternalDto object | MR diff |
| merge_request_reviewers_count | Integer | Number of scorers |
| merge_request_review_count | Integer | Scoring |
| merge_request_reviewer_list | Array of MergeRequestReviewerExternalDto objects | Scorer list |
| merge_request_assignee_list | Array of UserBasicExternalDto objects | Merger list |
| notes | Integer | Review comment |
| codecheck_state | Integer | Code check status |
| codecheck_defect_count | Integer | Code check issues |
| merge_request_related_work_items | Array of MergeRequestRelatedWorkItemDto objects | Number of associated tickets of an MR |
| diverged_commits_count | Integer | Number of commits that a source branch is behind |
| moderation_result | Boolean | Approving result |
| moderation_time | Long | Timestamp of approving submission Value range: 1~9223372036854775807 |
| moderation_status | Integer | Approving status code Value range: 1~2147483647 |
| is_use_temp_branch | Boolean | Use temporary branch or not |
| review_mode | String | Review mode |
| squash | Boolean | Squash merge |
| approval_merge_request_approvers | Array of ApprovalUserDto objects | Approver in the approval mode |
| approval_merge_request_reviewers | Array of ApprovalUserDto objects | Reviewer in the approval mode |
| source_repository | ProjectSimpleDto object | Source repository |
| target_repository | ProjectSimpleDto object | Target repository |
| is_source_branch_exist | Boolean | Source branch exists |
| merge_request_type | String | MR type |
| squash_commit_message | String | Squash commit information |
| auto_merge | Boolean | Auto merge |
| merge_error | String | Original MR error information |
| json_merge_error | MergeErrorDto object | MR error information |
| rebase_in_progress | Boolean | Whether rebase is in progress |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Milestone ID Value range: 1~2147483647 |
| iid | Integer | Milestone IID Value range: 1~2147483647 |
| repository_id | Integer | Repository ID. Value range: 1~2147483647 |
| title | String | Milestone title |
| description | String | Milestone description |
| state | String | Status |
| created_at | String | Creation time |
| updated_at | String | Update time. |
| due_date | String | Expiration time |
| start_date | String | Start time |
| repository_path | String | Repository path |
| web_url | String | Homepage URL |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | User ID Value range: 1~2147483647 |
| name | String | Name |
| username | String | Username |
| state | String | Status |
| avatar_url | String | Profile picture URL |
| web_url | String | Homepage URL |
| nick_name | String | User alias |
| tenant_name | String | Tenant name |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Diff ID of an MR Value range: 1~2147483647 |
| state | String | Status |
| merge_request_id | Integer | MR ID Value range: 1~2147483647 |
| created_at | String | Creation time |
| updated_at | String | Update time. |
| base_commit_sha | String | Base commit node |
| real_size | String | Number of diff files |
| head_commit_sha | String | Head commit node |
| start_commit_sha | String | Start commit node |
| commits_count | Integer | Number of commits Value range: 1~2147483647 |
| external_diff | String | External diff file |
| external_diff_store | Integer | External difference storage Value range: 1~2147483647 |
| stored_externally | Boolean | External storage or not |
| added_lines | Integer | Number of new lines Value range: 0~2147483647 |
| removed_lines | Integer | Number of deleted lines Value range: 0~2147483647 |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Scorer ID Value range: 1~2147483647 |
| username | String | Scorer name |
| name | String | Scorer name |
| nick_name | String | Scorer alias |
| state | Boolean | Scorer status |
| score | Integer | Scoring Value range: -2~2 |
| tenant_name | String | Tenant name |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Association ID Value range: 1~2147483647 |
| user_id | String | User ID |
| repo_id | Integer | Repository ID Value range: 1~2147483647 |
| merge_request_id | Integer | MR ID Value range: 1~2147483647 |
| target_branch | String | Target branch |
| source_branch | String | Source branch |
| merge_request_title | String | MR title |
| merge_request_url | String | MR URL |
| merge_request_state | String | MR status |
| related_id | String | Associated ticket ID |
| related_title | String | Associated ticket title |
| related_url | String | Associated ticket URL |
| result | Integer | Association result |
| message | String | Association result information |
| create_at | String | Creation time |
| update_at | String | Update time. |
| subject | String | Topic |
| tracker | Object | Ticket follower |
| status | Object | Status |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | User ID Value range: 1~2147483647 |
| username | String | Username |
| name | String | Username |
| nick_name | String | User alias |
| name_cn | String | Name (CN) |
| | String | |
| state | String | Status |
| updated_at | String | Update time |
| avatar_url | String | Profile picture URL |
| tenant_name | String | Tenant name |
| approver_comment | String | Approving comments |
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Repository ID. |
| description | String | Repository description |
| name | String | Repository name |
| name_with_namespace | String | Organization name/Organization name.../Repository name |
| path | String | Repository path |
| path_with_namespace | String | Complete repository path |
| created_at | String | Creation time |
| updated_at | String | Update time. |
| archived | Boolean | Archived or not |
| is_kia | Boolean | Confidential or not |
| ssh_url_to_repo | String | Repository SSH address |
| http_url_to_repo | String | Repository HTTP address |
| web_url | String | Repository page link |
| readme_url | String | Link to the readme file of the repository |
| project_id | String | Project ID |
| project_name | String | Project name |
| develop_mode | String | Repository development modes: normal and CR |
| moderation_result | Boolean | Approving status |
| Parameter | Type | Description |
|---|---|---|
| merge_user_name | String | Merger name |
| merge_start_time | String | Merge time |
| error_title | String | Error title |
| http_code_status | String | Status code |
| error_code | String | Error code |
| error_message | String | Error message |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition Error code. |
| error_msg | String | Definition Error message. |
Example Requests
/v4/repositories/123/import-merge-requests
{
"iid" : 9223372036854776000,
"source_uniq_key" : "string",
"author_id" : 9223372036854776000,
"state" : "string",
"title" : "string",
"description" : "string",
"source_branch" : "string",
"target_branch" : "string",
"target_repository_id" : "string",
"labels" : { },
"created_at" : "string",
"updated_at" : "string",
"merged_at" : "string",
"closed_at" : "string",
"approvers" : [ { } ],
"diff_refs" : {
"base_sha" : "ssssssssshhhhhhhhhhaaaa",
"start_sha" : "sssssssssshhhhhhhhhaaaa",
"head_sha" : "sssssssssxxxxxxxxaaaa"
},
"squash" : true,
"remove_source_branch" : true,
"branch_is_deleted" : true,
"fork" : true,
"import_source_from" : "string"
} Example Responses
Status code: 200
OK
{
"id" : 47858,
"iid" : 1,
"repository_id" : 2111983939,
"title" : "Create file d",
"description" : "merge \"ddd\" into \"master\"\nCreate file d",
"state" : "opened",
"created_at" : "2024-11-30T17:47:53.000+08:00",
"updated_at" : "2025-03-06T17:43:39.000+08:00",
"source_branch" : "ddd",
"target_branch" : "master",
"is_source_branch_protected" : false,
"devcloud_source_branch" : "ddd",
"author" : {
"id" : 9124,
"name" : "example_name",
"username" : "c369c68f1ff84679b5a8ed904d8bff1c",
"state" : "active",
"avatar_url" : "",
"web_url" : "https://example.com/c369c68f1ff84679b5a8ed904d8bff1c",
"nick_name" : "dev",
"tenant_name" : "example_name"
},
"source_repository_id" : 2111983939,
"target_repository_id" : 2111983939,
"source_project_id" : "3e1f6634946144c2b1ccb46fb8152b8f",
"target_project_id" : "3e1f6634946144c2b1ccb46fb8152b8f",
"labels" : [ ],
"work_in_progress" : false,
"milestone" : null,
"merge_when_build_succeeds" : false,
"merge_status" : "can_be_merged",
"sha" : "4f14849504009dd415b288f7ab21420933ecb516",
"merge_commit_sha" : null,
"subscribed" : true,
"merged_by" : null,
"merged_at" : null,
"closed_by" : null,
"closed_at" : null,
"user_notes_count" : 0,
"force_remove_source_branch" : false,
"web_url" : "https://example.com/********/2111983939/1/mergedetail?source=ddd&target=master",
"merge_request_diff" : {
"id" : 70760,
"state" : "collected",
"merge_request_id" : 47858,
"created_at" : "2024-11-30T17:47:53.000+08:00",
"updated_at" : "2024-11-30T17:47:53.000+08:00",
"base_commit_sha" : "c4f7b1bed9a869f64c90050311fad29ad4e40eb4",
"real_size" : "1",
"head_commit_sha" : "4f14849504009dd415b288f7ab21420933ecb516",
"start_commit_sha" : "c4f7b1bed9a869f64c90050311fad29ad4e40eb4",
"commits_count" : 1,
"external_diff" : "diff-70760",
"external_diff_store" : 1,
"stored_externally" : true,
"added_lines" : 1,
"removed_lines" : 0
},
"merge_request_reviewers_count" : 0,
"merge_request_review_count" : 0,
"merge_request_reviewer_list" : [ ],
"merge_request_assignee_list" : [ ],
"notes" : 0,
"codecheck_state" : 7,
"codecheck_defect_count" : 0,
"merge_request_related_work_items" : [ ],
"diverged_commits_count" : 6,
"moderation_result" : true,
"moderation_time" : 0,
"moderation_status" : 0,
"is_use_temp_branch" : false,
"review_mode" : "approval",
"squash" : false,
"approval_merge_request_approvers" : [ ],
"approval_merge_request_reviewers" : [ ],
"source_repository" : {
"id" : 2111983939,
"description" : "ddd",
"name" : "dddd",
"name_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f / dddd",
"path" : "dddd",
"path_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"created_at" : "2024-11-30T17:46:46.000+08:00",
"updated_at" : "2024-11-30T17:46:46.000+08:00",
"archived" : false,
"is_kia" : false,
"ssh_url_to_repo" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"http_url_to_repo" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"web_url" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"readme_url" : null,
"project_id" : "3e1f6634946144c2b1ccb46fb8152b8f",
"project_name" : null,
"develop_mode" : "normal",
"moderation_result" : true
},
"target_repository" : {
"id" : 2111983939,
"description" : "ddd",
"name" : "dddd",
"name_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f / dddd",
"path" : "dddd",
"path_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"created_at" : "2024-11-30T17:46:46.000+08:00",
"updated_at" : "2024-11-30T17:46:46.000+08:00",
"archived" : false,
"is_kia" : false,
"ssh_url_to_repo" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"http_url_to_repo" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"web_url" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"readme_url" : null,
"project_id" : "3e1f6634946144c2b1ccb46fb8152b8f",
"project_name" : null,
"develop_mode" : "normal",
"moderation_result" : true
},
"is_source_branch_exist" : true,
"merge_request_type" : "MergeRequest",
"squash_commit_message" : null,
"auto_merge" : false,
"merge_error" : null,
"json_merge_error" : null,
"rebase_in_progress" : false
} Status code: 401
Unauthorized
{
"error_code" : "DEV.00000003",
"error_msg" : "Authentication information expired."
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 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.