Skip to main content
Call this API to obtain role group information.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/role/getrolegroup
HTTP MethodPOST
Supported app typesappType-Internal appappType-Third-party enterprise app
Required permissionspermission-qyapi_get_department_list-Read permission for Contacts department information

Query parameter

NameTypeRequiredExampleDescription
access_tokenStringYesbE74xxxxThe 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 organization.

Request body

NameTypeRequiredExampleDescription
group_idNumberYes1507113580The ID of the role group.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/role/getrolegroup" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=ab02axxxx7d770' \
-d 'group_id=1'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/role/getrolegroup");
OapiRoleGetrolegroupRequest req = new OapiRoleGetrolegroupRequest();
req.setGroupId(1507113580L);
OapiRoleGetrolegroupResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiRoleGetrolegroupRequest("https://oapi.dingtalk.io/topapi/role/getrolegroup")

req.group_id=1
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
PHP
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiRoleGetrolegroupRequest;
$req->setGroupId("1");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/role/getrolegroup");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/role/getrolegroup");
OapiRoleGetrolegroupRequest req = new OapiRoleGetrolegroupRequest();
req.GroupId = 1L;
OapiRoleGetrolegroupResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
role_groupOpenRoleGroupThe role group information.
rolesOpenRole[]The list of roles.
role_idNumber1507113580The role ID.
role_nameStringSupervisorThe role name.
group_nameStringDefaultThe role group name.
errcodeNumber0The return code.
errmsgStringokThe description of the return code.
request_idString8lgzequlri0oThe request ID.

Response example

{
  "errcode": 0,
  "errmsg": "ok",
  "role_group": {
    "group_name": "Default",
    "roles": [
      {
        "role_name": "Owner",
        "role_id": 1507113580
      },
      {
        "role_name": "Supervisor",
        "role_id": 1507113581
      },
      {
        "role_name": "Super Admin",
        "role_id": 1507113578
      },
      {
        "role_name": "Sub Admin",
        "role_id": 1507113579
      }
    ]
  },
  "request_id": "8lgzequlri0o"
}

Error codes

If an error occurs when you call this API, refer to the Global error codes document to find a solution based on the error message.
Error code (errcode)Error message (errmsg)Solution
400002Invalid parameterVerify whether groupId is valid.
-1System is busyTry again later.