Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/role/scope/update |
| HTTP Method | POST |
| Supported app type | appType-Internal app |
| Required permissions | permission-qyapi_manage_addresslist-Contacts data management permission |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | Be3xxxx | The app credential for calling this API. Obtain it through the API for obtaining the access_token of an internal app. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| userid | String | Yes | EMP123 | The user ID of the employee in the organization. |
| role_id | Number | Yes | 12345 | The role ID. Call the Obtain a list of organization roles API to obtain the value of the id parameter. |
| dept_ids | String | No | 1231 | The list of department IDs. Separate multiple department IDs with commas. A maximum of 50 department IDs are supported. If left empty, the scope is set to all users. |
Request example
curl -X POST "https://api.dingtalk.io/topapi/role/scope/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=3100xxxx2280f5' \
-d 'dept_ids=1231' \
-d 'role_id=12345' \
-d 'userid=EMP123'
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/scope/update");
OapiRoleScopeUpdateRequest req = new OapiRoleScopeUpdateRequest();
req.setUserid("EMP123");
req.setRoleId(12345L);
req.setDeptIds("1231,2423");
OapiRoleScopeUpdateResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
import dingtalk.api
req=dingtalk.api.OapiRoleScopeUpdateRequest("https://api.dingtalk.io/topapi/role/scope/update")
req.userid="EMP123"
req.role_id=12345
req.dept_ids="1231"
try:
resp= req.getResponse(access_token)
print(resp)
except Exception,e:
print(e)
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiRoleScopeUpdateRequest;
$req->setUserid("EMP123");
$req->setRoleId("12345");
$req->setDeptIds("1231,2423,53536");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/scope/update");
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/scope/update");
OapiRoleScopeUpdateRequest req = new OapiRoleScopeUpdateRequest();
req.Userid = "EMP123";
req.RoleId = 12345L;
req.DeptIds = "1231";
OapiRoleScopeUpdateResponse 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. |
| request_id | String | 4pe0h4hlsit9 | The request ID. |
Response body example
{
"errcode":"0",
"errmsg":"ok",
"request_id":"4pe0h4hlsit9"
}
Error codes
If an error is returned when calling this API, find the solution in the Global error codes document based on the error message.| Error code (errcode) | Error code description (errmsg) | Solution |
|---|---|---|
| 40003 | Invalid userId | Verify that the userId is correct. |
| 34018 | role_id cannot be empty | Provide the roleId. |
| 60301 | Invalid role_id | Verify that the role_id is correct. |
| 60003 | Department does not exist | Verify that the dept_ids are correct. |
| 46004 | Employee is not in the organization | Verify that the parameters are correct. |
| 400002 | Invalid parameter | Verify that the request parameters are correct. |
| -1 | System busy | Try again later. |