Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/role/list |
| HTTP Method | POST |
| Supported app types | appType-Internal app, appType-Third-party enterprise app |
| Permissions | permission-qyapi_get_department_list-Read permission for Contacts department information |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | 6ed1bxxx | The app credential used to call this API. - For an internal app, obtain it through the API for getting the access_token of an internal app. - For a third-party enterprise app, obtain it through the API for getting the access_token of a third-party enterprise. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| size | Number | No | 20 | Supports paginated queries. Takes effect only when set together with the offset parameter. This parameter represents the page size. Default is 20. Maximum is 200. |
| offset | Number | No | 0 | Supports paginated queries. Takes effect only when set together with the size parameter. This parameter represents the offset, which starts from 0. |
Request example
curl -X POST "https://api.dingtalk.io/topapi/role/list" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=a0a639xxxx2998' \
-d 'offset=0' \
-d 'size=20'
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/list");
OapiRoleListRequest req = new OapiRoleListRequest();
req.setSize(20L);
req.setOffset(0L);
OapiRoleListResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
import dingtalk.api
req=dingtalk.api.OapiRoleListRequest("https://api.dingtalk.io/topapi/role/list")
req.size=20
req.offset=0
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 OapiRoleListRequest;
$req->setSize("20");
$req->setOffset("0");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/list");
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/list");
OapiRoleListRequest req = new OapiRoleListRequest();
req.Size = 20L;
req.Offset = 0L;
OapiRoleListResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| request_id | String | ii8a42qgzu7e | The request ID. |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| result | PageVo | The result list. | |
| hasMore | Boolean | false | Whether more data is available. |
| list | OpenRoleGroup[] | The role group list. | |
| name | String | Default | The role group name. |
| groupId | Number | 1507113577 | The role group ID. |
| roles | OpenRole[] | The role list. | |
| name | String | Admin | The role name. |
| id | Number | 1507113578 | The role ID. |
Response body example
{
"errcode": 0,
"result": {
"hasMore": true,
"list": [
{
"groupId": 1507113577,
"name": "Default",
"roles": [
{
"id": 1507113580,
"name": "Owner"
},
{
"id": 1507113581,
"name": "Manager"
},
{
"id": 1507113578,
"name": "Super Admin"
},
{
"id": 1507113579,
"name": "Sub Admin"
}
]
}
]
},
"request_id": "ii8a42qgzu7e"
}
Error codes
If an error is returned when you call this API, find a solution in the Global error codes document based on the error message.| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 400043 | Invalid orgId | Check whether the access_token is correct. |
| 40069 | Invalid size | Adjust the page size. |
| 40068 | Invalid offset | Adjust the offset. |
| 400001 | System error | Try again later. |