获取证据集
返回生物识别采集过程中生成的证据包——其中包含采集的图像、元数据以及用于证明活体检测是在受控条件下执行的采集产物。
仅适用于已完成的流程(state = PROCESS_STATE_FINISHED)。
端点
| 环境 | URL |
|---|---|
| 生产环境 | GET https://api.idcloud.unico.app/client/v1/process/{processId}/evidenceset |
| 沙箱环境 | GET https://api.idcloud.uat.unico.app/client/v1/process/{processId}/evidenceset |
请求
请求头
| 请求头 | 值 |
|---|---|
Authorization | Bearer <access_token>(参见身份验证) |
路径参数
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
processId | string (UUID) | 是 | 创建流程返回的流程标识符。 |
示例
- cURL
- Node.js
curl -X GET https://api.idcloud.unico.app/client/v1/process/$PROCESS_ID/evidenceset \
-H "Authorization: Bearer $TOKEN" \
| jq -r .fileContents | base64 --decode > evidence-set.pdf
import { writeFile } from 'node:fs/promises';
async function getEvidenceSet(processId) {
const response = await fetch(
`https://api.idcloud.unico.app/client/v1/process/${processId}/evidenceset`,
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
if (!response.ok) throw new Error(`Get Evidence Set failed with ${response.status}`);
const { fileContents } = await response.json();
// fileContents 是经过 base64 编码的 PDF 文件
return Buffer.from(fileContents, 'base64');
}
// 将 PDF 保存到磁盘
await writeFile(`evidence-set-${processId}.pdf`, await getEvidenceSet(processId));
// 或发送到浏览器(Express)
app.get('/processes/:id/evidence-set', async (req, res) => {
const pdf = await getEvidenceSet(req.params.id);
res
.type('application/pdf') // 不要转发 contentType:该 API 返回的是 "x-pdf"
.set('Content-Disposition', 'inline; filename="evidence-set.pdf"')
.send(pdf);
});
响应
200 OK
{
"fileContents": "JVBERi0xLjMNCi...",
"contentType": "x-pdf"
}
| 字段 | 类型 | 描述 |
|---|---|---|
fileContents | string (base64) | 证据集 PDF,经过 base64 编码。 |
contentType | string | 目前返回 x-pdf。 |
构建 PDF
x-pdf 不是有效的 MIME 类型,浏览器无法识别它。请勿将 contentType 转发给浏览器。将 fileContents 从 base64 解码,并按照上面 Node.js 示例中的方式以 application/pdf 的 形式提供字节数据。
错误代码
备注
该 API 不会为此端点暴露具体的 code 或 message 值。
- 400 Bad Request
- 401 Unauthorized
- 404 Not Found
- 500 Internal Server Error
processId 路径参数缺失或格式错误。
Bearer 令牌缺失、已过期或无效。参见身份验证。
未找到流程,或证据集尚未生成(流程尚未完成)。
| 代码 | 消息 | 描述 |
|---|---|---|
99999 | Internal failure! Try again later | 发生内部错误时。 |