跳转到主要内容
调用本接口获取指定部门的用户基础信息。

接口调用说明

  • 本接口只支持获取员工的userId和name两个字段信息,如需获取部门下员工详情信息,请参考获取部门用户详情
  • 本接口只支持获取当前部门内的员工基础信息,子部门内员工信息获取不到。

请求

基本信息
HTTP URLhttps://oapi.dingtalk.io/topapi/user/listsimple
HTTP MethodPOST
支持的应用类型appType-企业内部应用appType-第三方企业应用
权限要求permission-qyapi_get_department_member-通讯录部门成员读权限

查询参数

名称类型是否必填示例值描述
access_tokenStringbE74xxxx调用该API的应用凭证。 - 企业内部应用,通过获取企业内部应用的access_token接口获取。 - 第三方企业应用,通过获取第三方企业的access_token接口获取。

请求体

名称类型是否必填示例值描述
dept_idNumber10部门ID,如果是根部门,该参数传1,可调用获取部门列表获取dept_id参数值。
cursorNumber0分页查询的游标,最开始传0,后续传返回参数中的next_cursor值。
sizeNumber10分页长度,最大值100。
order_fieldStringmodify_desc部门成员的排序规则。默认值,custom。 - entry_asc:代表按照进入部门的时间升序。 - entry_desc:代表按照进入部门的时间降序。 - modify_asc:代表按照部门信息修改时间升序。 - modify_desc:代表按照部门信息修改时间降序。 - custom:代表用户定义(未定义时按照拼音)排序。
contain_access_limitBooleanfalse是否返回访问受限的员工。 - true:是 - false:否
languageStringzh_CN通讯录语言,取值。 - zh_CN:中文(默认值)。 - en_US:英文。

请求示例

curl -X POST "https://oapi.dingtalk.io/topapi/user/listsimple" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=c1f2d110-4e7c-4536-a340-06652613e0c1' \
-d 'contain_access_limit=false' \
-d 'cursor=0' \
-d 'dept_id=10' \
-d 'language=zh_CN' \
-d 'order_field=modify_desc' \
-d 'size=10'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/user/listsimple");
OapiUserListsimpleRequest req = new OapiUserListsimpleRequest();
req.setDeptId(10L);
req.setCursor(0L);
req.setSize(10L);
req.setOrderField("modify_desc");
req.setContainAccessLimit(false);
req.setLanguage("zh_CN");
OapiUserListsimpleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiUserListsimpleRequest("https://oapi.dingtalk.io/topapi/user/listsimple")

req.dept_id=10
req.cursor=0
req.size=10
req.order_field="modify_desc"
req.contain_access_limit=false
req.language="zh_CN"
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 OapiUserListsimpleRequest;
$req->setDeptId("10");
$req->setCursor("0");
$req->setSize("10");
$req->setOrderField("modify_desc");
$req->setContainAccessLimit("false");
$req->setLanguage("zh_CN");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/user/listsimple");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/user/listsimple");
OapiUserListsimpleRequest req = new OapiUserListsimpleRequest();
req.DeptId = 10L;
req.Cursor = 0L;
req.Size = 10L;
req.OrderField = "modify_desc";
req.ContainAccessLimit = false;
req.Language = "zh_CN";
OapiUserListsimpleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

响应

响应体

名称类型示例值描述
request_idString4f9md9obopn2请求ID。
errcodeNumber0返回码,0代表成功。
errmsgStringok返回码描述。
resultPageResult返回结果。
has_moreBooleantrue是否还有更多的数据。 - true:是 - false:否
next_cursorNumber10下一次分页的游标,如果has_more为false,表示没有更多的分页数据。
listListUserSimpleResponse[]用户信息列表。
useridStringzxxxxx用户的userid。
nameString张三用户姓名。

响应体示例

{
  "errcode": 0,
  "errmsg": "ok",
  "result": {
    "has_more": false,
    "list": [
      {
        "name": "测试用户2",
        "userid": "user100"
      },
      {
        "name": "李思",
        "userid": "user1"
      }
    ]
  },
  "request_id": "x4p6arvi0fzj"
}

错误码

若调用该接口报错,可根据错误信息在全局错误码文档中查找解决方案。
错误码(errcode)错误码描述(errmsg)解决方案
400002无效的参数请确认参数按上述要求填写
60003未找到对应部门请确认部门id是否正确
40069无效的size请调整分页的大小
40068无效的偏移量请调整偏移量
-1系统繁忙请稍后再试