查询批量任务执行状态
该接口用于查询通讯录异步任务当前的执行状态以及执行结果。
Warning: 应用商店应用无权限调用此接口。 调用该接口需要申请
更新通讯录以及以应用身份读取通讯录权限。
请求
| 项目 | 值 |
|---|---|
| HTTP URL | https://open.feishu.cn/open-apis/contact/v2/task/get?task_id=0123456789abcdef0123456789abcdef |
| HTTP Method | GET |
| 权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可 | 更新通讯录 以应用身份访问通讯录(历史版本) |
请求头
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | string | 是 | tenant_access_token 值格式:"Bearer access_token" 示例值:"Bearer t-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token |
| Content-Type | string | 是 | 固定值:"application/json; charset=utf-8" |
请求参数
| 参数 | 类型 | 必填 / 选填 | 示例 | 说明 |
|---|---|---|---|---|
| task_id | string | 必填 | 0123456789abcdef0123456789abcdef | 批量任务接口返回的异步任务 ID。 |
响应
响应体
| 参数 | 说明 |
|---|---|
| code | 返回码,非 0 表示失败。 |
| msg | 对返回码的文本描述。 |
| data | - |
| ∟task_id | 异步任务 ID。 |
| ∟type | 任务类型,目前有两种,添加用户时为 add_user,添加部门时为 add_department。 |
| ∟status | 任务当前执行状态,小于 9:正在执行过程中,9:执行完成,10:执行失败。 |
| ∟progress | 任务执行进度百分比。 |
| ∟total_num | 任务总条数。 |
| ∟success_num | 任务当前执行成功的条数。 |
| ∟fail_num | 任务当前执行失败的条数。 |
| ∟create_time | 任务创建时间,以秒为单位的 Unix 时间戳。 |
| ∟finish_time | 任务完成时间,以秒为单位的 Unix 时间戳,当任务未完成时不返回此字段。 |
| ∟task_info | 任务执行结果列表,当任务非正常执行完成时不返回此字段。 列表中的执行结果顺序和创建任务时请求体中的子任务顺序一致。 |
| ∟code | 子任务返回码,非 0 表示失败。 |
| ∟msg | 对子任务返回码的文本描述。 |
| ∟action | 子任务进行的操作,1:添加,2:更新。子任务执行失败时不返回此字段。 |
| ∟name | 子任务请求名称,用户操作时为用户名,部门操作时为部门名。 |
| ================ | 以下字段适用于在用户操作时: |
| 请求时的用户邮箱。 | |
| ∟mobile | 请求时的用户手机号。 |
| ∟user_id | 请求时的用户企业内唯一标识。 当请求时没有填写 user_id 字段并且子任务执行成功时,字段值为系统生成的唯一标识。 |
| ∟departments | 请求时的用户所属部门。 |
| ∟open_id | 生成的用户 open_id,子任务执行失败时不返回此字段。 |
| ================ | 以下字段适用于在部门操作时: |
| ∟department_id | 请求时的自定义部门 ID。 当请求时没有填写自定义 ID 字段并且子任务执行成功时,字段值为系统生成的部门 ID。 |
| ∟parent_id | 请求时的父部门 ID。 |
| ∟chat_id | 部门群 ID,部门群不存在时不返回此字段。 |
响应体示例
当异步任务为用户操作时:
json
{
"code": 0,
"msg": "success",
"data": {
"task_id": "123456784b68a7c89abcdef092dc09ea",
"type": "add_user",
"status": 8,
"progress": 100,
"total_num": 2,
"success_num": 1,
"fail_num": 1,
"create_time": 1565878519,
"finish_time": 1565878523,
"task_info": [
{
"code": 0,
"msg": "success",
"action": 1,
"departments": [
"custom_1"
],
"email": "custom_1@feishu.cn",
"mobile": "13000000001",
"name": "custom_1",
"open_id": "ou_123456784b68a7c89abcdef092dc09ea",
"user_id": "custom_1"
},
{
"code": 10013,
"msg": "invalid user_id",
"departments": [
"custom_2"
],
"mobile": "13000000002",
"name": "custom_2",
"user_id": "_custom_2"
}
]
}
}当异步任务为部门操作时:
json
{
"code": 0,
"msg": "success",
"data": {
"task_id": "123456784b68a7c89abcdef092dc09ea",
"type": "add_department",
"status": 8,
"progress": 100,
"total_num": 2,
"success_num": 2,
"fail_num": 0,
"create_time": 1565878519,
"finish_time": 1565878523,
"task_info": [
{
"code": 0,
"msg": "success",
"action": 1,
"chat_id": "oc_123456784b68a7c89abcdef092dc09ea",
"department_id": "custom_1",
"name": "custom_1",
"parent_id": "0"
},
{
"code": 0,
"msg": "success",
"action": 1,
"department_id": "custom_2",
"name": "custom_2",
"parent_id": "custom_1"
}
]
}
}错误码
具体可参考:服务端错误码说明
