> ## 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.

# Update a role name

> Call this API to update a role name. Roles in the Default group, including owner, supervisor, super admin, and sub-admin, cannot be modified.

Call this API to update a role name. This API does not allow you to modify roles in the "Default" group, including Person in charge, Supervisor, Super Admin, and Sub Admin.

## Request

| **Basic information** |                                                                                         |
| --------------------- | --------------------------------------------------------------------------------------- |
| HTTP URL              | [https://oapi.dingtalk.io/role/update\_role](https://oapi.dingtalk.io/role/update_role) |
| HTTP Method           | POST                                                                                    |
| Supported app types   | appType-Internal app                                                                    |
| Required permissions  | permission-qyapi\_manage\_addresslist-Contacts data management permission               |

### Query parameters

| Name          | Type   | Required | Example  | Description                                                                                                                                                    |
| ------------- | ------ | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | 6d1bxxxx | The app credential used to call this API. Obtain it through the API for getting the [access\_token of an internal app](/open/development/obtain-orgapp-token). |

### Request body

| Name     | Type   | Required | Example               | Description                                                                                                                                                                                                                                                      |
| -------- | ------ | -------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| roleId   | Number | Yes      | 1560985325            | The ID of the role to update. You can obtain it by calling the [Get role list](/open/development/obtains-a-list-of-enterprise-roles) API.  Roles in the "Default" group cannot be modified, including: Person in charge, Supervisor, Super Admin, and Sub Admin. |
| roleName | String | Yes      | Apparel manufacturing | The new role name.                                                                                                                                                                                                                                               |

### Request example

```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("Apparel manufacturing");
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);
```

## Response

### Response body

| Name    | Type   | Example | Description                         |
| ------- | ------ | ------- | ----------------------------------- |
| errcode | Number | 0       | The return code.                    |
| errmsg  | String | ok      | The description of the return code. |

### Response body example

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

### Error codes

If an error occurs when calling this API, refer to the [Global error codes](/open/development/server-api-error-codes-1) document to find a solution based on the error message.

| Error code (errcode) | Error message (errmsg) | Solution                         |
| -------------------- | ---------------------- | -------------------------------- |
| 660000               | The parameter is empty | Complete the missing parameters. |
| 33011                | Invalid roleId         | Check whether roleId is correct. |
| -1                   | The system is busy     | Try again later.                 |
