Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/role/getrole |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app |
| Required permissions | permission-qyapi_get_department_member-Read permission for Contacts department users |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | bE74xxxx | 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 |
|---|---|---|---|---|
| roleId | Number | Yes | 1581321999 | The role ID. To get the value of the id parameter, call the Get role list API. |
Request example
curl -X POST "https://api.dingtalk.io/topapi/role/getrole" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=2c9ecxxxx4210' \
-d 'roleId=1001'
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrole");
OapiRoleGetroleRequest req = new OapiRoleGetroleRequest();
req.setRoleId(1507113578L);
OapiRoleGetroleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
import dingtalk.api
req=dingtalk.api.OapiRoleGetroleRequest("https://api.dingtalk.io/topapi/role/getrole")
req.roleId=1001
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 OapiRoleGetroleRequest;
$req->setRoleId("1001");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/getrole");
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrole");
OapiRoleGetroleRequest req = new OapiRoleGetroleRequest();
req.RoleId = 1001L;
OapiRoleGetroleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| role | OpenRole | The role information. | |
| name | String | Owner | The role name. |
| groupId | Number | 1507113577 | The ID of the role group that the role belongs to. |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request_id | String | 4cmr6app8ujf | The request ID. |
Response example
{
"errcode":0,
"role":{
"groupId":1507113577,
"name":"Owner"
},
"request_id":"4cmr6app8ujf"
}
Error codes
If an error occurs when you call this API, find the solution in the Global error codes document based on the error message.| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 33011 | Invalid roleId | Verify that the roleId is correct. |
| 43007 | Operation permission required | Verify that the access_token has the required permissions. |
| 400001 | System error | Try again later. |