获取单个父部门下的子部门。可选择只返回直属的一级子部门,或所有后代部门。
departments:read
GET{域名}/openapi/v1/departments/{id}/children| Header 参数 | 是否必填 | 描述 |
|---|---|---|
Authorization |
是 | 固定取值为 Bearer {access_token}。关于如何获取访问令牌,参考鉴权。 |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
|
|
string |
是 |
- |
父部门 ID。 部门 ID 可以通过 ”按关键词搜索部门“ 接口获取。 |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
|
|
bool |
否 |
|
是否递归返回子部门。
|
page |
int | 否 | 1 |
需返回的页数。 |
page_size |
int | 否 | 100 |
每页返回的子部门数量。取值范围:[1, 500]。 |
该接口独有的响应参数如下,参数位于 data 中。通用响应参数参考此文档。
| 参数 | 类型 | 描述 |
|---|---|---|
items |
array | 子部门列表。 |
items[].department_id |
string | 子部门的 ID。 |
|
|
string |
子部门所属的父部门的真实 ID,根部门为 提示:递归查询时,对于更深层级的子部门,该参数返回的值可能不等于请求路径中的 |
items[].name |
string | 子部门的名称。 |
items[].full_path |
string | 子部门的完整归属路径。各级部门名称以 / 分隔。 |
items[].depth |
int | 子部门的层级深度。根部门为 0。 |
curl -X GET "${HOST}/openapi/v1/departments/0/children?recursive=true&page=1&page_size=100" \
-H "Authorization: Bearer ${ACCESS_TOKEN}"
{
"code": 0,
"message": "success",
"request_id": "req_xxx",
"data": {
"items": [
{
"department_id": "20001",
"parent_department_id": "90001",
"name": "研发一部",
"full_path": "示例企业/研发一部",
"depth": 1
}
],
"pagination": {
"page": 1,
"page_size": 100,
"total": 1,
"total_pages": 1
}
}
}
若该接口的请求返回错误码,参考错误码文档进行排查。