请求
| 基本信息 | |
|---|---|
| HTTP URL | https://oapi.dingtalk.io/role/add_role |
| HTTP Method | POST |
| 支持的应用类型 | appType-企业内部应用 |
| 权限要求 | permission-qyapi_manage_addresslist-通讯录数据管理权限 |
查询参数
| 名称 | 类型 | 是否必填 | 示例值 | 描述 |
|---|---|---|---|---|
| access_token | String | 是 | 6d1bxxxx | 调用该接口的应用凭证,通过获取企业内部应用的access_token接口获取。 |
请求体
请求示例
curl -X POST "https://oapi.dingtalk.io/role/add_role" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=2e3f55xxxx6e34' \
-d 'groupId=11' \
-d 'roleName=test'
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/add_role");
OapiRoleAddRoleRequest req = new OapiRoleAddRoleRequest();
req.setRoleName("测试1");
req.setGroupId(1507113595L);
OapiRoleAddRoleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
import dingtalk.api
req=dingtalk.api.OapiRoleAddRoleRequest("https://oapi.dingtalk.io/role/add_role")
req.roleName="test"
req.groupId=11
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 OapiRoleAddRoleRequest;
$req->setRoleName("test");
$req->setGroupId("11");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/role/add_role");
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/add_role");
OapiRoleAddRoleRequest req = new OapiRoleAddRoleRequest();
req.RoleName = "test";
req.GroupId = 11L;
OapiRoleAddRoleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
响应
响应体
| 名称 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| roleId | Number | 1688611118 | 角色ID。 |
| errcode | Number | 0 | 返回码。 |
| errmsg | String | ok | 返回码描述。 |
响应体示例
{
"errcode":0,
"roleId":1688611118,
"errmsg":"ok"
}
错误码
若调用该接口报错,可根据错误信息在全局错误码文档中查找解决方案。| 错误码(errcode) | 错误码描述(errmsg) | 解决方案 |
|---|---|---|
| 34018 | 角色不能为空 | 请填上roleName和groupId |
| 34020 | 无效的groupId | 请检查groupId是否正确 |
| 34021 | 角色名称已存在 | 请检查roleName是否正确 |
| -1 | 系统繁忙 | 请稍后再试 |