[comment]: # ({0ba948d5-0f96d4e3})
# 更新

[comment]: # ({/0ba948d5-0f96d4e3})

[comment]: # ({d595df91-c5c262c6})
### 描述

`object connector.update(object/array connectors)`

此方法允许更新现有的连接器。

::: noteclassic
此方法仅对*超级管理员*用户类型可用。在用户角色设置中可以撤销调用此方法的权限。
有关更多信息，请参阅[用户角色](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/d595df91-c5c262c6})

[comment]: # ({227630cd-7604a8a7})
### 参数

`(object/array)` 要更新的连接器属性。

必须为每个连接器定义 `connectorid` 属性，其他所有属性均为可选。
仅会更新已传递的属性，其他所有属性将保持不变。

除了[标准连接器属性](object#connector)外，该方法还接受以下参数。

|参数|[类型](/manual/api/reference_commentary#data-types)|描述|
|--|--|------|
|tags|array|用于替换当前标签过滤器的连接器[标签过滤器](/manual/api/reference/connector/object#tag-filter)。|

[comment]: # ({/227630cd-7604a8a7})

[comment]: # ({ce3e1358-aed16236})
### 返回值

`(object)` 返回一个对象，该对象在`connectorids`属性下包含已更新的连接器的ID。

[comment]: # ({/ce3e1358-aed16236})

[comment]: # ({b41637d2-20154cf3})
### 示例

[comment]: # ({/b41637d2-20154cf3})

[comment]: # ({e1aaffff-4bc523df})
#### 更改HTTP认证类型

将ID为"3"的连接器的HTTP认证类型更改为Bearer。

[请求](/manual/api#执行请求)：

```json
{
    "jsonrpc": "2.0",
    "method": "connector.update",
    "params": {
        "connectorid": 3,
        "authtype": 5,
        "token": "{$DATA_EXPORT_BEARER_TOKEN}"
    },
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "connectorids": [
            "3"
        ]
    },
    "id": 1
}
```

[comment]: # ({/e1aaffff-4bc523df})

[comment]: # ({246e1630-c1adf037})
#### 更新标签过滤

更改ID为"5"的连接器标签。

[请求](/manual/api#执行请求):

```json
{
    "jsonrpc": "2.0",
    "method": "connector.update",
    "params": [
        {
            "connectorid": 5,
            "tags_evaltype": 2,
            "tags": [
                {
                    "tag": "service",
                    "operator": 0,
                    "value": "mysqld"
                },
                {
                    "tag": "error",
                    "operator": 12,
                    "value": ""
                }
            ]
        }
    ],
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "connectorids": [
            "5"
        ]
    },
    "id": 1
}
```

[comment]: # ({/246e1630-c1adf037})

[comment]: # ({37d671ce-f93b099e})
### 源码位置

CConnector::update() 在 *ui/include/classes/api/services/CConnector.php文件中。

[comment]: # ({/37d671ce-f93b099e})
