
# 云测复制测试用例和用例脚本 - CreateTMSSCaseAndCopyScript
#### 功能介绍
云测根据工程唯一标识和用例脚本信息复制测试用例和用例脚本
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-testman/cloudtest_03_2000.html)。
#### URI
POST /v2/{project_id}/testcase/copy
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|:---|
| project_id | 是    | String | **参数解释**: 项目UUID，项目唯一标识，固定长度32位字符（字母和数字）。获取方式请参见[获取项目ID](https://support.huaweicloud.com/api-testman/cloudtest_03_4003.html) **约束限制**: 不涉及 **取值范围**: 项目uuid应符合如下规则：长度等于32位字符，包含大小写字母、数字 **默认取值**: 不涉及 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | **参数解释：** 用户Token。 通过调用IAM服务[获取用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)接口获取（响应消息头中X-Subject-Token的值）。 **约束限制：** 必传。 **取值范围：** 字符串长度不少于1，不超过10万。 **默认取值：** 不涉及。 |
   
表3请求Body参数 
| 参数                                     | 是否必选 | 参数类型   | 描述     |
|:---|:---|:---|:---|
| CreateTMSSCaseAndCopyScriptRequestBody | 是    | String | 用例脚本信息 |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数     | 参数类型                                                                                                     | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|
| error  | [CommonResponseErrorOfobject] object | **参数解释** 统一错误返回 **取值范围** 不涉及                                                                                                                                                                                                                                                                                                                                                                                                                         |
| reason | String                                                                                                   | **参数解释** 接口调用失败原因 **取值范围** 不超过1000个字符组成的字符串                                                                                                                                                                                                                                                                                                                                                                                                          |
| result | Object                                                                                                   | **参数解释** 结果 **取值范围** 不涉及                                                                                                                                                                                                                                                                                                                                                                                                                             |
| status | String                                                                                                   | **参数解释** '状态值，如success、error' **取值范围** - success，请求成功   - error，请求报错    |
   
 表5CommonResponseErrorOfobject 
| 参数     | 参数类型   | 描述                                                                                                                                                                                       |
|:---|:---|:---|
| code   | String | **参数解释** 接口调用失败错误码 **取值范围** 不超过256个字符组成的字符串 |
| reason | String | **参数解释** 接口调用失败原因 **取值范围** 不超过1000个字符组成的字符串 |
   
**状态码：201**
Created
**状态码：401**
表6响应Body参数 
| 参数         | 参数类型   | 描述                                                                                                                                                                                        |
|:---|:---|:---|
| error_code | String | **参数解释** 接口调用失败错误码 **取值范围** 12-18个字符组成的字符串   |
| error_msg  | String | **参数解释** 接口调用失败错误信息 **取值范围** 3-1000个字符组成的字符串 |
   
**状态码：403**
表7响应Body参数 
| 参数         | 参数类型   | 描述                                                                                                                                                                                        |
|:---|:---|:---|
| error_code | String | **参数解释** 接口调用失败错误码 **取值范围** 12-18个字符组成的字符串   |
| error_msg  | String | **参数解释** 接口调用失败错误信息 **取值范围** 3-1000个字符组成的字符串 |
   
**状态码：404**
表8响应Body参数 
| 参数         | 参数类型   | 描述                                                                                                                                                                                        |
|:---|:---|:---|
| error_code | String | **参数解释** 接口调用失败错误码 **取值范围** 12-18个字符组成的字符串   |
| error_msg  | String | **参数解释** 接口调用失败错误信息 **取值范围** 3-1000个字符组成的字符串 |
   
#### 请求示例
```
"{
    "name": "TestCase_qAlGX_IJdpU_copy",
    "script_name": "TestCase_qAlGX_N1R10_copy",
    "create_time_string": "",
    "update_time_string": "",
    "releaseDev": "",
    "tmss_case_uri": "",
    "tmss_feature_uri": "",
    "activity_id": 1,
    "tmss_property": {
        "projectUUId": "fb4a997e9c0d4b13aa0bf230f6f62d53",
        "type": 1,
        "asstype": 1,
        "name": "TestCase_qAlGX_mnlbo_copy",
        "description": "",
        "preparation": "",
        "scriptUrl": "",
        "steps": [
            {
                "testStep": "",
                "expectResult": ""
            }
        ],
        "number": "",
        "level": "2",
        "moduleId": "",
        "releaseDev": "",
        "releaseId": "",
        "ownerId": "",
        "test_type": 1,
        "labelId": [],
        "issueId": "",
        "r_issueName": "",
        "cataId": "",
        "exe_platform": "apitest",
        "planId": ""
    },
    "import_info_list": [],
    "case_variable_list": [],
    "aw_instance": {
        "setup_aw_list": [],
        "test_aw_list": [],
        "teardown_aw_list": []
    },
    "source": "cloudtest",
    "issueId": "",
    "relate_type": "requirement",
    "feature_uri": "",
    "old_tmss_case_uri": "v92s00010hrjv7pg"
}"
```
#### 响应示例
**状态码：200**
SUCCESS
```
{
  "status" : "success",
  "result" : {
    "id" : "afa42e9100304aa8806d4beeffbebd2c",
    "name" : "123_2625",
    "deleteFlag" : null,
    "changeSign" : 0,
    "planId" : null,
    "issueId" : "",
    "addToPlan" : null,
    "releaseDev" : "",
    "copyFlag" : true,
    "source" : "cloudtest",
    "region" : "{region}",
    "status" : null,
    "create_time_stamp" : 1720081655000,
    "update_time_stamp" : null,
    "create_time_string" : "2024-07-04 16:27:35 GMT+08:00",
    "update_time_string" : null,
    "create_user" : "devcloud_devcloud_s00314720_01",
    "create_time" : "2024-07-04T04:27:35+0800",
    "update_user" : null,
    "update_time" : null,
    "tmss_property" : {
      "name" : "123_2625",
      "description" : "",
      "number" : "105",
      "cataId" : null,
      "labelId" : [ ],
      "tags" : null,
      "level" : 2,
      "preparation" : "",
      "market" : null,
      "remark" : null,
      "originUri" : null,
      "releaseDev" : "",
      "stage" : null,
      "moduleId" : "",
      "releaseId" : "",
      "customField1" : null,
      "customField2" : null,
      "customField3" : null,
      "customField4" : null,
      "customField5" : null,
      "customField6" : null,
      "customField7" : null,
      "customField8" : null,
      "custom_field_1" : null,
      "custom_field_2" : null,
      "custom_field_3" : null,
      "custom_field_4" : null,
      "custom_field_5" : null,
      "custom_field_6" : null,
      "custom_field_7" : null,
      "custom_field_8" : null,
      "custom_field_9" : null,
      "custom_field_10" : null,
      "custom_field_11" : null,
      "custom_field_12" : null,
      "custom_field_13" : null,
      "custom_field_14" : null,
      "custom_field_15" : null,
      "custom_field_16" : null,
      "custom_field_17" : null,
      "custom_field_18" : null,
      "custom_field_19" : null,
      "custom_field_20" : null,
      "custom_field_21" : null,
      "custom_field_22" : null,
      "custom_field_23" : null,
      "custom_field_24" : null,
      "custom_field_25" : null,
      "uri" : null,
      "node_name" : null,
      "test_type" : 1,
      "testStep" : null,
      "test_step" : null,
      "expectOutput" : null,
      "expect_output" : null,
      "env_type" : null,
      "exe_platform" : "apitest",
      "auto_type" : "1",
      "is_contract_testcase" : null,
      "is_paraValidator_testcase" : null,
      "test_feature" : null,
      "last_modified" : null,
      "last_modifier" : null,
      "author" : null,
      "creation_date" : null,
      "activity_id" : null,
      "owner" : null,
      "feature_path" : null,
      "ownerId" : "",
      "dr_relationid" : null,
      "applied_product" : null,
      "last_result" : null,
      "isKeyWord" : null,
      "steps" : [ {
        "testStep" : "",
        "expectResult" : ""
      } ],
      "networkScriptName" : null,
      "svnScriptPath" : null
    },
    "project_id" : "b7cb42f3fec14acba074624ddccd30db",
    "logic_case_id" : null,
    "activity_id" : "1",
    "package_name" : "scripts.user",
    "script_name" : "Case_afa42e9100304aa8806d4beeffbebd2c_1",
    "script_path" : "src/scripts/user/Case_afa42e9100304aa8806d4beeffbebd2c_1.java",
    "tmss_case_uri" : "v91k0000vm823f04",
    "aw_instance" : {
      "setup_aw_list" : [ ],
      "test_aw_list" : [ {
        "id" : "897c954a5dc5467585a6fe4bebc1121b",
        "projectId" : "b7cb42f3fec14acba074624ddccd30db",
        "changeSign" : 0,
        "region" : "{region}",
        "relation" : "",
        "children" : null,
        "scriptName" : null,
        "create_time_stamp" : 1720081655000,
        "update_time_stamp" : 1720078110000,
        "create_time_string" : "2024-07-04 16:27:35 GMT+08:00",
        "update_time_string" : "2024-07-04 15:28:30 GMT+08:00",
        "create_user" : "devcloud_devcloud_s00314720_01",
        "create_time" : "2024-07-04T04:27:35+0800",
        "update_user" : "devcloud_devcloud_s00314720_01",
        "update_time" : "2024-07-04T03:28:30+0800",
        "name" : null,
        "condition_type" : 20,
        "condition_statement" : "1000",
        "body_param_type" : null,
        "aw_type" : 1,
        "aw_id" : "",
        "basic_aw" : null,
        "param_type_and_value" : [ ],
        "check_point_list" : [ ],
        "variable_list" : [ ],
        "retry_times" : "",
        "retry_interval" : "",
        "by_order" : 0,
        "from_outside" : null,
        "service_and_stage" : null,
        "is_contract_aw" : null,
        "is_sectest_aw" : null,
        "is_disabled" : 0,
        "param_dependent" : null,
        "param_dependent_enabled" : null,
        "relation_id" : null,
        "relation_type" : 0,
        "extra_info" : null,
        "custom_header" : [ ],
        "level" : null,
        "hasLevel" : null,
        "is_basic" : 1,
        "his_script" : null,
        "description" : null,
        "aw_description" : null,
        "user_id" : null,
        "special_type" : 0,
        "error_info" : null,
        "alias_runaw" : null,
        "authentication_type" : null,
        "authentication_info" : null,
        "output_alias_info" : null,
        "header_array" : null
      } ],
      "teardown_aw_list" : [ ]
    },
    "case_variable_list" : [ ],
    "quality_check_time" : null,
    "quality_check_result" : null,
    "tc_comments" : null,
    "import_info_list" : [ ],
    "IteratorCaseUri" : null,
    "IsKeyWord" : 0,
    "keyword_id" : null,
    "all_variable_names" : null,
    "variableGroupId" : null,
    "error_step" : null,
    "import_edit" : 5,
    "user_id" : null,
    "case_type" : 0
  },
  "reason" : null,
  "error" : null
}
```
#### 状态码
| 状态码 | 描述           |
|:---|:---|
| 200 | SUCCESS      |
| 201 | Created      |
| 401 | Unauthorized |
| 403 | Forbidden    |
| 404 | Not Found    |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-testman/ErrorCode.html)。
