按部门 ID 批量获取多个部门的信息。
departments:read
POST{域名}/openapi/v1/departments/batch-get若在请求中传入重复的部门 ID,系统会自动去重,并仅在 items 中返回一次该部门的信息。
| Header 参数 | 是否必填 | 描述 |
|---|---|---|
Authorization |
是 | 固定取值为 Bearer {access_token}。关于如何获取访问令牌,参考鉴权。 |
Content-Type |
是 | 固定取值为 application/json。 |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
|
|
string[] |
是 |
- |
部门 ID 列表。范围为 1 至 100 个。 部门 ID 可以通过 “获取单个父部门的子部门” 接口或 ”按关键词搜索部门“ 接口获取。 |
该接口独有的响应参数如下,参数位于 data 中。通用响应参数参考此文档。
| 参数 | 类型 | 描述 |
|---|---|---|
items |
array | 查询到的部门列表。按请求中的部门 ID 顺序返回。 |
items[].department_id |
string | 部门 ID。 |
items[].parent_department_id |
string | 直属父部门的 ID。根部门为 "0"。 |
items[].name |
string | 部门名称。 |
items[].full_path |
string | 部门的完整归属路径。各级部门名称以 / 分隔。 |
items[].depth |
int | 部门的层级深度。根部门为 0。 |
not_found_department_ids |
string[] | 未找到或不属于当前企业的部门的 ID。返回请求中传入的原始值。 |
curl -X POST "${HOST}/openapi/v1/departments/batch-get" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"department_ids": [
"0",
"20001",
"99999"
]
}'
{
"code": 0,
"message": "success",
"request_id": "req_xxx",
"data": {
"items": [
{
"department_id": "90001",
"parent_department_id": "0",
"name": "示例企业",
"full_path": "示例企业",
"depth": 0
},
{
"department_id": "20001",
"parent_department_id": "90001",
"name": "研发一部",
"full_path": "示例企业/研发一部",
"depth": 1
}
],
"not_found_department_ids": ["99999"]
}
}
若该接口的请求返回错误码,参考错误码文档进行排查。