> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ロール名の更新

> ロール名を更新します。責任者や上司などデフォルトロールは変更対象外になります。

本インターフェースを呼び出して、ロール名を更新します。本インターフェースでは、「デフォルト」グループ分け内のロール（責任者、上司、スーパー管理者、サブ管理者を含む）の変更は許可されません。

## リクエスト

| **基本情報**    |                                                                                         |
| ----------- | --------------------------------------------------------------------------------------- |
| HTTP URL    | [https://oapi.dingtalk.io/role/update\_role](https://oapi.dingtalk.io/role/update_role) |
| HTTP Method | POST                                                                                    |
| 対応するアプリタイプ  | appType-社内アプリ                                                                           |
| 必要な権限       | permission-qyapi\_manage\_addresslist-連絡先データ管理権限                                        |

### クエリパラメータ

| 名前            | タイプ    | 必須 | 例        | 説明                                                                                                              |
| ------------- | ------ | -- | -------- | --------------------------------------------------------------------------------------------------------------- |
| access\_token | String | はい | 6d1bxxxx | 本インターフェースを呼び出すためのアプリ認証情報。[社内アプリの access\_token を取得する](/ja/open/development/obtain-orgapp-token)インターフェースから取得します。 |

### リクエストボディ

| 名前       | タイプ    | 必須 | 例          | 説明                                                                                                                                                       |
| -------- | ------ | -- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| roleId   | Number | はい | 1560985325 | 更新するロールID。[ロールリストの取得](/ja/open/development/obtains-a-list-of-enterprise-roles)インターフェースを呼び出して取得できます。 「デフォルト」グループ分け内のロール（責任者、上司、スーパー管理者、サブ管理者を含む）は変更できません。 |
| roleName | String | はい | アパレル製造     | 変更後のロール名。                                                                                                                                                |

### リクエスト例

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://oapi.dingtalk.io/role/update_role" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=bb0d689c-e415-4fa5-b5d8-e16741e12b87' \
-d 'roleId=1' \
-d 'roleName=11'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/update_role");
OapiRoleUpdateRoleRequest req = new OapiRoleUpdateRoleRequest();
req.setRoleId(1560985325L);
req.setRoleName("アパレル製造");
OapiRoleUpdateRoleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiRoleUpdateRoleRequest("https://oapi.dingtalk.io/role/update_role")

req.roleId=1
req.roleName="11"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiRoleUpdateRoleRequest;
$req->setRoleId("1");
$req->setRoleName("11");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/role/update_role");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/update_role");
OapiRoleUpdateRoleRequest req = new OapiRoleUpdateRoleRequest();
req.RoleId = 1L;
req.RoleName = "11";
OapiRoleUpdateRoleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## レスポンス

### レスポンスボディ

| 名前      | タイプ    | 例  | 説明          |
| ------- | ------ | -- | ----------- |
| errcode | Number | 0  | リターンコード。    |
| errmsg  | String | ok | リターンコードの説明。 |

### レスポンスボディの例

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "errmsg":"ok"
}
```

### エラーコード

本インターフェースの呼び出しでエラーが発生した場合は、エラーメッセージに基づき [グローバルエラーコード](/ja/open/development/server-api-error-codes-1) ドキュメントで解決方法を検索してください。

| エラーコード（errcode） | エラーコードの説明（errmsg） | 解決方法                 |
| --------------- | ----------------- | -------------------- |
| 660000          | パラメータが空です         | パラメータを補完してください       |
| 33011           | 無効な roleId        | roleId が正しいか確認してください |
| -1              | システムビジー           | 後で再試行してください          |
