华为云WELINK-对外开放:如何调用应用对外开放接口

时间:2025-05-23 20:41:11

如何调用应用对外开放接口

本节以查询统计图表接口说明调用应用对外开放接口时如何使用密钥。

请求地址:

https://roundtable.welink.huaweicloud.com/api/avatar/platform/gateway/com.huawei.avatar:avatar_core/avatar/core/api/core/v1/themes/query-chart

请求方法:post(HTTPS

请求消息头:附加请求头字段,应用访问密钥需要添加至请求中。

Open-Api-auth:Bearer 应用生成的访问密钥

请求参数:

data '{
    "dataSetId": "829393867627281408ba63186eef2164b595b5",
    "countContext": {
        "category": "bBCVNzwq__ym9T__ CS T",
        "countField": "",
        "countType": "1",
        "componentType": "input",
        "componentExt": ""
    },
    "filterContexts": [
        {
            "fieldName": "lastModifiedDate",
            "symbol": "gte",
            "type": "and",
            "valType": "String",
            "value": "2025-03-07 00:00:00"
        },
        {
            "fieldName": "lastModifiedDate",
            "symbol": "lte",
            "type": "and",
            "valType": "String",
            "value": "2025-04-07 23:59:59"
        }
    ]
}
表1 请求参数说明

参数

必填

类型

说明

componentType

string

图表数据类型,可取的值有adminPie饼图、adminBar柱状图、adminLine折线图

countContext

CountContext

图表统计参数

eventTemplateId

string

事件模板ID(事件模板ID与数据集ID二选一)

dataSetId

string

数据集ID(事件模板ID与数据集ID二选一)

filterContexts

FilterContexts

是筛选条件的数组,其中每个元素对象都包含5个字段

表2 CountContext参数

参数

必填

类型

说明

category

string

表示图表上要统计的字段,如果是饼图,只有一个,折线图、柱状图有两个,使用“;”分割

countType

int

1统计总数、2求和、3平均值、4最大值、5最小值

countField

string

countType如果值不是1,这个值必须要传入,传入表单的字段名

componentType

string

该字段用来指定category中字段在表单上对应的组件类型,对应关系为:input输入框、adminmultiselect下拉多选、checkboxgroup复选按钮、radiogroup单选按钮、select下拉单选、userList人员组件、adminTask关联模板、adminCascading级联组件、organizationSelect部门组件

componentExt

string

饼图为空,柱状图、折线图时传值["",""]

表3 FilterContexts参数

参数

必填

类型

说明

fieldName

string

字段名称。通过圆桌轻应用构建服务创建的表单,字段名称和页面上字段的对应关系可以在模板构建页面查询

symbol

string

操作符。例如,操作符“eq”表示等于,“ne”表示不等于,“gt”表示大于,“lt”表示小于,“ge”表示大于等于,“le”表示小于等于。“contains”表示包含

type

string

条件关联关系,and表示条件都要满足,or表示至少要满足一个条件

valType

string

值的类型String字符串,Array数组

value

string

参数值

请求示例:

curl -X POST
'https://roundtable.welink.huaweicloud.com/api/avatar/platform/gateway/com.huawei.avatar:avatar_core/avatar/core/api/core/v1/themes/query-chart
 \
--header 'Accept: */*' \
--header 'Accept-Language: zh-CN,zh;q=0.9' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: https://roundtable.welink.huaweicloud.com' \
--header 'Referer: https://roundtable.welink.huaweicloud.com/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-origin' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36' \
--header 'avatar-csrf-token: 529218cc625d8fdc9e1b871467a93371c713b7cffb423f2f' \
--header 'sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "Windows"' \
--header 'Open-Api-auth: Bearer 829394676978062336edd39f477f57db0eca63_72573257774749491293ca9099a769b2923e6d_f36b2cba3c72d1050515cc3e97a2e2648fa3f9032bf15c34ac350ec4a7f80e61267122a452b3dd987a43356cfd6258b9c9bc05426445e648094b637055411bbe' \
--data '{
    "dataSetId": "829393867627281408ba63186eef2164b595b5",
    "countContext": {
        "category": "bBCVNzwq__ym9T__CST",
        "countField": "",
        "countType": "1",
        "componentType": "input",
        "componentExt": ""
    },
    "filterContexts": [
        {
            "fieldName": "lastModifiedDate",
            "symbol": "gte",
            "type": "and",
            "valType": "String",
            "value": "2025-03-07 00:00:00"
        },
        {
            "fieldName": "lastModifiedDate",
            "symbol": "lte",
            "type": "and",
            "valType": "String",
            "value": "2025-04-07 23:59:59"
        }
    ]
}

响应结果示例

  "code": 200,
  "data": {
    "result": {
      "log": "",
      "value": {
        "result": [
          {
            "nameValue": "第一个",
            "field": "YHSwdHgM__stfd__CST",
            "name": "第一个",
            "value": [
              {
                "nameValue": "第一个",
                "field": "YHSwdHgM__z8dZ__CST",
                "name": "第一个",
                "value": 1
              }
            ]
          },
          {
            "nameValue": "第二个",
            "field": "YHSwdHgM__stfd__CST",
            "name": "第二个",
            "value": [
              {
                "nameValue": "第二个",
                "field": "YHSwdHgM__z8dZ__CST",
                "name": "第二个",
                "value": 2
              }
            ]
          },
          {
            "nameValue": "第3个",
            "field": "YHSwdHgM__stfd__CST",
            "name": "第3个",
            "value": [
              {
                "nameValue": "第3个",
                "field": "YHSwdHgM__z8dZ__CST",
                "name": "第3个",
                "value": 3
              }
            ]
          }
        ],
        "resCode": 0,
        "resMsg": "成功"
      }
    }
  },
  "message": "OK"
}

Result返回一个数组,如果是饼图,代表每一块的数据nameValue为具体的值,field对应表单的字段,name代表展示的名称,value代表值。如果是折线图、柱状图,外层为横轴数据,内层value为纵坐标上的数据。

表4 响应参数说明

参数

类型

说明

result

string

Result为查询到的表单数据,是对象数据,每个对象对应表单中的每条记录,其中通过圆桌轻应用构建服务创建的表单,字段名称和页面上字段的对应关系可以在模板构建页面查询。

code

string

成功 200;失败返回对应圆桌错误码

message

string

success or 对应错误信息

support.huaweicloud.com/usermanual-welink/welink_pcuse_roundtable_281.html
提示

您即将访问非华为云网站,请注意账号财产安全