按关键字搜索企业内的部门。支持不区分大小写的模糊匹配。
departments:read
GET{域名}/openapi/v1/departments/search| Header 参数 | 是否必填 | 描述 |
|---|---|---|
Authorization |
是 | 固定取值为 Bearer {access_token}。关于如何获取访问令牌,参考鉴权。 |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
|
|
string |
是 |
- |
搜索关键字,最长为
|
page |
int | 否 | 1 |
需返回的页数。 |
page_size |
int | 否 | 100 |
每页返回的部门数量。取值范围:[1, 500]。 |
该接口独有的响应参数如下,参数位于 data 中。通用响应参数参考此文档。
items |
array | 部门列表。 |
|---|---|---|
items[].department_id |
string | 部门的 ID。 |
items[].parent_department_id |
string | 部门直属的父部门的 ID,根部门为 "0"。 |
items[].name |
string | 部门的名称。 |
items[].full_path |
string | 部门的完整归属路径。各级部门名称以 / 分隔。 |
items[].depth |
int | 部门的层级深度。根部门为 0。 |
curl -X GET "${HOST}/openapi/v1/departments/search?keyword=%E7%A0%94%E5%8F%91&page=1" \
-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
}
}
}
若该接口的请求返回错误码,参考错误码文档进行排查。