# 修改事务 - UpdateTemp
#### 功能介绍
修改事务
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CPTS/doc?api=UpdateTemp)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-cpts/cpts_api_0019.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                                         | 访问级别  | 资源类型（\*为必须） | 条件键                       | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | codeartsperftest:cpts:updatePerfTestProject | Write | cpts \*     | g:ResourceTag/\<tag-key\> | -  | -      |
     
  
 
#### URI
PUT /v1/{project_id}/templates/{template_id}
表1路径参数 
| 参数          | 是否必选 | 参数类型    | 描述                                                                              |
|:---|:---|:---|:---|
| template_id | 是    | Integer | 事务ID，通过"创建事务"接口获取响应体中的tempId字段的值。                                               |
| project_id  | 是    | String  | 表示项目ID，参见[获取方法说明](https://support.huaweicloud.com/api-cpts/cpts_api_0017.html)。 |
   
#### 请求参数
表2请求Body参数 
| 参数              | 是否必选 | 参数类型                                                                     | 描述                                |
|:---|:---|:---|:---|
| id              | 是    | Integer                                                                  | 事务ID，通过"创建事务"接口获取响应体中的tempId字段的值。 |
| project_id      | 是    | Integer                                                                  | 工程ID                              |
| name            | 是    | String                                                                   | 事务名称                              |
| temp_type       | 否    | Integer                                                                  | 事务类型                              |
| description     | 否    | String                                                                   | 描述信息                              |
| for_loop_params | 否    | Array of objects                                                         | 旧版本逻辑控制器字段，当前已不使用                 |
| enable_pre      | 否    | Boolean                                                                  | 是否启用预置事务，当前版本已不使用                 |
| contents        | 否    | Array of [TempContentInfo] objects | 事务脚本信息                            |
   
 表3TempContentInfo 
| 参数         | 是否必选 | 参数类型                                                     | 描述                                                                                 |
|:---|:---|:---|:---|
| content_id | 否    | Integer                                                  | 报文id或者事务ID或者插件ID                                                                   |
| content    | 否    | Array of [Content] objects | 内容                                                                                 |
| index      | 否    | Integer                                                  | 索引                                                                                 |
| data       | 否    | Object                                                   | 数据指令内容                                                                             |
| data_type  | 否    | Integer                                                  | 数据指令类型（0：默认请求卡片；1：数据指令；201：循环指令；202：条件指令；301：集合点；203：vu百分比控制器；204：吞吐量控制器；302：插件请求） |
   
 表4Content 
| 参数           | 是否必选 | 参数类型                                                   | 描述                               |
|:---|:---|:---|:---|
| content_type | 是    | Integer                                                | 用例卡片类型（1：思考时间；2：报文；3：检查点；4：变量提取） |
| content      | 是    | [ContentInfo] object | 内容                               |
   
 表5ContentInfo 
| 参数                   | 是否必选 | 参数类型                                                                 | 描述                                                                          |
|:---|:---|:---|:---|
| body_type            | 是    | Integer                                                              | body类型（0：字符串；1：form-data格式；3：x-www-form-urlencoded格式）                       |
| bodys                | 否    | Array of objects                                                     | 请求体                                                                         |
| check_end_length     | 否    | Object                                                               | TCP/UDP协议返回数据长度                                                             |
| check_end_str        | 否    | Object                                                               | TCP/UDP协议返回结束符                                                              |
| check_end_type       | 否    | Object                                                               | TCP/UDP协议返回结束类型（1：返回数据长度；2：结束符）                                             |
| connect_timeout      | 否    | Integer                                                              | 超时时间                                                                        |
| connect_type         | 否    | Integer                                                              | 连接设置，当前版本已不使用                                                               |
| headers              | 否    | Array of [ContentHeader] objects | 请求头                                                                         |
| http_version         | 是    | String                                                               | HTTP版本                                                                      |
| method               | 是    | String                                                               | HTTP方法                                                                      |
| name                 | 是    | String                                                               | 用例名称                                                                        |
| protocol_type        | 否    | Integer                                                              | 协议类型（1：HTTP；2：HTTPS；3：TCP；4：UDP；7：HLS/RTMP；9：WebSocket；10：HTTP-FLV；11：MQTT） |
| return_timeout       | 是    | Integer                                                              | 响应超时                                                                        |
| return_timeout_param | 否    | String                                                               | 响应超时参数                                                                      |
| url                  | 是    | String                                                               | 请求地址                                                                        |
| rtmp_url             | 否    | String                                                               | rtmp地址                                                                      |
| flv_url              | 否    | String                                                               | flv地址                                                                       |
| bitrate_type         | 否    | Integer                                                              | 分辨率策略                                                                       |
| duration             | 否    | Integer                                                              | 持续时间                                                                        |
| retry_delay          | 否    | Integer                                                              | HLS重试延迟时间                                                                   |
| retry_time           | 否    | Integer                                                              | HLS重试次数                                                                     |
   
 表6ContentHeader 
| 参数    | 是否必选 | 参数类型   | 描述 |
|:---|:---|:---|:---|
| key   | 是    | String | 键  |
| value | 是    | String | 值  |
   
#### 响应参数
**状态码：204**
无
**状态码：501**
表7响应Body参数 
| 参数 | 参数类型   | 描述               |
|:---|:---|:---|
| -  | String | response message |
   
#### 请求示例
修改一个事务，事务的id是1，事务所属的工程ID是1，包括修改事务的请求信息。
```
/v1/{project_id}/templates/1
{
  "contents" : [ {
    "content" : [ {
      "content" : {
        "body_type" : 0,
        "bodys" : [ ],
        "check_end_length" : null,
        "check_end_str" : null,
        "check_end_type" : null,
        "connect_timeout" : 5000,
        "connect_type" : 1,
        "headers" : [ {
          "key" : "Content-Type",
          "value" : "application/json"
        } ],
        "http_version" : "HTTP/1.1",
        "method" : "GET",
        "name" : "Msg-31445",
        "protocol_type" : 2,
        "return_timeout" : 5000,
        "return_timeout_param" : null,
        "url" : "https://www.domain-example.com"
      },
      "content_type" : 2
    } ],
    "content_id" : 2346,
    "index" : 0
  } ],
  "description" : "",
  "enable_pre" : false,
  "for_loop_params" : [ ],
  "id" : 1,
  "name" : "transaction_test",
  "project_id" : 1,
  "temp_type" : 0
}
```
#### 响应示例
无
#### 状态码
| 状态码 | 描述            |
|:---|:---|
| 204 | success       |
| 501 | unknown error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-cpts/ErrorCode.html)。
