当前位置:网站首页>【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结
【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结
2022-06-10 13:19:00 【nginx】
1.注册订阅通知能力后,连通性检查失败
在注册成为订阅者后,测试连通性检查回调通知地址时,提示“连通性检查失败,连通性检查响应非204”。

原因分析:
在回调通知地址可以访问的情况下,需要开发者确认订阅的回调通知地址的HTTP状态码是否为204,否则将返回404表示回调地址连通性检验失败。
参考订阅数据文档
解决方案:
检查链接是否可用,且返回的状态码是否为204。
2.采样数据统计接口返回的步数总和与获取步数明细数据后自己计算的总和不一致
用采样数据统计查询接口获取步数总和
统计查询接口:https://health-api.cloud.huawei.com/healthkit/v1/sampleSet:polymerize
请求参数:
最终返回的步数结果为7118
{"polymerizeWith": [{": 1651809600000,"startTime": 1651766400000,"groupByTime": {"groupPeriod": {"timeZone": "+0800","unit": "day","value": 1}}}

用采样数据明细查询接口获取步数明细,并计算总和
明细查询接口:https://health-api.cloud.huawei.com/healthkit/v1/sampleSet:polymerize
请求参数:
根据返回的结果计算的步数总和为6280
{"polymerizeWith": [{"dataTypeName": "com.huawei.continuous.steps.delta"}],"endTime": 1651809600000,"startTime": 1651766400000}

通过数据可以看出,在时间段相同的前提下,采样数据统计接口返回的步数总和与根据步数明细计算的总和是不一致的。
原因分析:
是明细数据和统计数据不同的机制导致的。明细数据和统计数据是分开上报的,由于各种原因,明细数据可能会有丢失或延迟,导致两种数据不能完全匹配。
其次,在统计一天的数据时,聚合条件为以下参数时(见下图),返回的是上报的统计数据,而不是通过明细数据计算的数据。

解决方案:
采样数据统计查询时,按时间聚合,传入groupByTime参数,groupByTime中设置duration参数。
请求参数:
最终返回的结果是6280,与根据步数明细计算的总和一致。
{"polymerizeWith": [{"dataTypeName": "com.huawei.continuous.steps.delta"}],"endTime": 1651809600000,"startTime": 1651766400000,"groupByTime": {"duration": 86400000}}

3.错误码403,错误信息“Insufficient Permission: Request had insufficient authentication scopes.”

原因分析:
403为拒绝请求,主要是scopes权限不足,导致拒绝请求。
解决方案:
(1)检查联盟卡片中是否申请了相关权限。

(2)检查认证鉴权时是否传入了申请的权限,且是否在授权页面进行了同意授权。

认证鉴权时是否传入了申请的权限
授权界面是否勾选了权限

4.错误码400,错误信息“Insufficient Permission: Request had insufficient authentication scopes.”
案例:查询步数的采样数据明细
参数说明:
Access Token:根据首次认证鉴权的code码生成。
首次认证鉴权的时间(第一次生成code码的时间):2022年5月7日上午8点左右。
采集数据的起始时间:
开始时间:2022-05-06 00:00:00(1651766400000)
结束时间:2022-05-06 12:00:00(1651809600000)
具体请求,见下图:

响应结果:

原因分析:
查询数据时,出于对用户数据的保护,只允许开发者查询在用户授权之后的数据。如果需要查询用户授权前的数据,开发者需要获取到“读取历史数据”权限的授权,如果用户未授予此权限,开发者在查询数据时设置的起始时间若早于用户授权时间,则起始时间将自动修正为用户首次授权的时间,这将导致查询错误(code:400,message: “Invalid startTime or endTime.”)或仅能查询到用户授权时间后的数据,与设置的起始时间不一致。
拿问题中的例子来说,由于用户未授予“读取历史数据”的权限,在开始时间为5月6日,首次授权时间为5月7日的情况下,开始时间会自动修正为首次授权时间,也就是5月7日,这就导致修正后的开始时间晚于了结束时间,因此才会返回了错误码400,错误信息"Invalid startTime or endTime."。
解决方案:
(1)检查Health Kit 联盟卡片上是否申请了“读取历史数据”权限,此权限在服务器应用中可见

(2)生成授权码code时, 在scope中添加"https://www.huawei.com/healthkit/historydata.open"权限,供用户在登录华为帐号之后为应用授予“读取历史数据”。
授权之后查询的数据:

了解更多详情>>
访问华为运动健康服务联盟官网
访问华为运动健康场景解决方案
获取华为运动健康服务开发指导文档
边栏推荐
- Yyds dry goods inventory # solve the problem of sword finger offer: jump step expansion
- 【NLP】NLP全路径学习推荐
- 常识,神经元数量,小鼠的脑内神经元大约在7000万个、人类约有860亿个
- High performance practical Alibaba sentinel notes, in-depth restoration of Alibaba micro service high concurrency scheme
- Google Earth Engine(GEE)——利用MODIS 的叶面积指数影像掩膜dem批量下载
- 高性能实战Alibaba Sentinel笔记,深度还原阿里微服务高并发方案
- typescript入门笔记(个人用)
- Comprehensive training of large projects
- Pycharm安装详细教程
- 出海企业遇瓶颈 茄子科技(SHAREit Group)有话说
猜你喜欢

【无标题】

解决win10虚拟机和主机不能互相粘贴复制的问题

The deep neural network classifies nearly 2billion images per second, and the new brain like optical classifier chip is on nature

"Reduce the burden" so that the "pig" can fly higher

Final exam - Principles of compilation
![buuctf [PHP]CVE-2019-11043](/img/ba/d97fe48acfd20daa66d47f34d99cf1.png)
buuctf [PHP]CVE-2019-11043
![buuctf [GlassFish]任意文件读取](/img/37/e3c127f2f2ba97c5ca0b6cf01cf9ab.png)
buuctf [GlassFish]任意文件读取
![[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service](/img/73/c6c4c0d92e5adb2e831ea4a0290ee9.jpg)
[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service
![buuctf [Discuz]wooyun-2010-080723](/img/b9/d63c9c638ff7c390c490d6fd5eafd1.png)
buuctf [Discuz]wooyun-2010-080723

Unity typewriter to automatically roll text to the bottom of the text box
随机推荐
What are the common automated test frameworks? Shanghai software testing company Amway
leetcode-57-插入区间
Pycharm安装详细教程
buuctf [PHP]inclusion
[笔记]Windows安全之《三》Shellcode 补充之 Get-InjectedThread脚本搭建环境及其使用
Copying and deleting files
buuctf [PHP]CVE-2019-11043
谷歌提出超强预训练模型CoCa,在ImageNet上微调Top-1准确率达91%!在多个下游任务上SOTA!
不吐不快
施一公等团队登Science封面:AI与冷冻电镜揭示「原子级」NPC结构,生命科学突破
'getWidth()' is deprecated,'getHeight()' is deprecated
超详细的FFmpeg安装及简单使用教程
【深度学习】基于深度学习Autoencoder的信用卡欺诈异常检测,效果非常牛逼
[yellow code] SVN version control tutorial
Comparison of two BigDecimal data types, addition, subtraction, multiplication and division, and formatting
QT database application 22 file coding format recognition
Yyds dry goods inventory # solve the problem of sword finger offer: jump step expansion
【Multisim仿真】差分放大电路2
2022大厂高频软件测试面试真题(附答案)
Nanomq newsletter 2022-05 | release of V0.8.0, new webhook extension interface and connection authentication API