EnOS 报表工具 API 概述¶
EnOS 报表工具是助力零代码定制报表模板和管理日常报表任务的轻量级工具。更多信息,参见 EnOS 报表工具。
报表工具提供一系列 API 服务,赋能报表设计、生成和调度的全生命周期,包括管理报表模板及其参数,生成报表,报表任务排错等。
有关如何调用 EnOS API 的信息,参见 EnOS API 快速入门。
API 服务列表¶
报表工具 API 提供以下 Open API 服务。
操作名称 | 描述 | URL | 适用于 EnOS Cloud | 适用于 EnOS Edge |
---|---|---|---|---|
Create Report Template | 新建报表模板 | /report-design-service/v1.0/report-file?action=create | √ | × |
Update Report Template | 更新报表模板 | /report-design-service/v1.0/report-file?action=update | √ | × |
Query Report Template | 查询单个报表模板 | /report-design-service/v1.0/report-file?action=query | √ | × |
Query Series Report Template | 查询一系列报表模板 | /report-design-service/v1.0/report-file/list?action=query | √ | × |
Delete Report Template | 删除报表模板 | /report-design-service/v1.0/report-file?action=delete | √ | × |
Query Template Parameter | 查询报表模板参数 | /report-design-service/v1.0/report-file/arguments?action=query | √ | × |
Generate Report | 生成报表 | /report-runtime-service/v1.0/report?action=create | √ | × |
API 版本¶
下表列出报表工具企业版与轻量版包含的 API 服务。
操作名称 | 企业版 | 轻量版 |
---|---|---|
Create Report Template | √ | √ |
Update Report Template | √ | √ |
Query Report Template | √ | √ |
Query Series Report Template | √ | √ |
Delete Report Template | √ | √ |
Query Template Parameter | √ | √ |
Generate Report | √ | √ |
API 请求¶
报表工具 API 请求包含请求 URI 和请求消息头两部分。
请求 URI¶
METHOD https://{api-gateway}/{service-name}/{version}/{endpoint-url}?{action=<action>&{ }}
其中:
METHOD
:请求方法。例如:GET
或POST
。api-gateway
:API 服务的网关地址。例如:app-portal-xxx.enos-iot.com
。可通过登入 EnOS 管理控制台,点击右上角的 帮助 > 环境信息 里 API 网关 中获取。service-name
:API 服务名称。例如:report-design-service
或report-runtime-service
。version
:API 版本。目前支持v1.0
。endpoint-url
:资源和对资源的操作。例如:report-file
或preview
。action=<action>&
:查询参数,如果有多个参数,使用&
作为分隔符。例如:action=query&orgId=yourOrgId
。
请求消息头(Header)¶
REST API 规范和 HTTP 规范所需的任何其他字段,绑定在请求消息头中。
常用的请求消息头为 Content-Type
,代表数据提交方式,一般情况下它的值可设为 application / json; charset = UTF-8
;若执行文件上传或其他表单提交,值设为 multipart / form-data; charset = UTF-8
。
请求参数 (Body)¶
每个 API 接口中请求消息体的参数有所不同。以下表格介绍用来指定报表模板的请求参数。
名称 | 数据类型 | 描述 |
---|---|---|
reportKey | String | 报表模板的密钥(key)。 |
reportId | String | 报表模板的 ID。 |
originalId | String | 报表模板的源 ID。 |
在一个请求中同时使用以上参数时,参数的优先级如下:
reportId
(最高) > reportKey
> originalId
(最低)。
请求示例¶
#requestURI:
https://{api-gateway}/report-design-service/v1.0/report-file?orgId=yourOrgId&action=update
#requestbody:
{
"file": "yourFileLocation",
"reportKey": "yourKey",
"category": "R",
"type": "cus"
"originalId":"originalReportId"
}
API 返回结果¶
API 返回 JSON 结构体,格式如下:
{
"msg": "{message}",
"code": {code},
"data": {data},
"success": {true/false}
}
返回参数¶
对返回参数的详细说明如下:
名称 | 数据类型 | 描述 |
---|---|---|
msg | String | 对状态码的解释和说明。成功为 Success 。若 API 请求失败,返回具体错误信息。 |
code | Integer | API 请求状态码,0 表示请求成功。有关状态码含义,参见 返回码。 |
data | Array 或 Object | API 响应返回结果集,数据类型包括:基本数据类型、复杂类型或数组。 |
success | String | 报表工具 API 返回 true 或 false 表明 API 请求是否成功。 |
返回码 ¶
对所有返回码的详细说明如下:
Code | Message | 描述 |
---|---|---|
0 | Success | 请求成功。 |
93001 | Request parameters are non-compliance. Illegal parameters are { } | 请求中包含非法参数。 |
93002 | Request body is non-compliance. Illegal request body is { } | 请求中包含非法消息体。 |
93008 | Error occurred when downloading files from the remote storage. File path is { } | 无法从 blob 或 S3 中下载文件。 |
93009 | Error occurred when parsing report arguments. | 无法解析参数。 |
93010 | No available report or no permission to query reports. Report file IDs are :/query operation error.condition:{ } | 查询报表失败。 |
93012 | Error occurred when generating reports. Download URL is { }, type is { }, category is { } | 生成报表失败。 |
93013 | Found more than one rptdesign files in zip folder. Files are { } | ZIP 文件中包含多个 rptdesign 文件。 |
93014 | No rptdesign found: neither a single file nor a zip file is uploaded. | 无法找到合法的 rptdesign 文件。 |
93015 | zip file is broken | ZIP 文件已损坏。 |
93016 | rptdesign file is not compliance: the mime type must be XML while the current mime type is { } | 检测到非法的 rptdesign 文件。 |
93017 | Error occurred when processing report parameters, msg : { }/rptdesign file contains sensitive string | 生成报表过程中检测到不正确的报表参数。 |
93018 | Render report exception, report file name : { } , render type : {}, locale { } | 生成报表过程中渲染报表失败。 |
93028 | Report key is in use: report Key { } , type { } , category { } | 报表模板密钥已存在。 |
93029 | No available records found from database, query criteria are { } , we expected at least { } | 当前条件下无查询结果。 |
93030 | Report key { } is not consistent with the root key | 当前报表模板与源报表模板的密钥不一致。 |
93070 | Error occurred when uploading files to remote storage. File path is { } | 无法将文件上传至 blob 或 S3。 |
93071 | Error occurred when uploading files, type : { } , category : { } , file name : { } | 上传文件失败。 |
93072 | Failed to initialize report context | 报表初始化失败。 |
93074 | Could not find the authority rptdesign, condition { }, orgId{ } | 无法找到符合条件的 rptdesign 文件。 |
返回示例¶
返回成功示例。
{
"msg": "Success",
"code": 0,
"data": {
"reportId": "yourReportId",
"fileName": "reportFileName.rptdesign"
},
"success": true
}
返回失败示例。
{
"msg": "Report key yourEnteredKey is not consistent with the root key ",
"code": 93030,
"success": false
}