当前位置:网站首页>【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"权限,供用户在登录华为帐号之后为应用授予“读取历史数据”。
授权之后查询的数据:

了解更多详情>>
访问华为运动健康服务联盟官网
访问华为运动健康场景解决方案
获取华为运动健康服务开发指导文档
边栏推荐
- 拷贝和删除文件
- Recommend an efficient IO component - okio
- High performance practical Alibaba sentinel notes, in-depth restoration of Alibaba micro service high concurrency scheme
- 2022 ciscn preliminary PWN complete WP
- Comprehensive training of large projects
- 'getcolor (int) 'is deprecated, getcolor is obsolete
- 常见的自动化测试框架有哪些?上海软件测试公司安利
- NanoMQ Newsletter 2022-05|v0.8.0 发布,新增 WebHook 拓展接口和连接认证 API
- CL210OpenStack操作的故障排除--常见核心问题的故障排除
- Comparison of two BigDecimal data types, addition, subtraction, multiplication and division, and formatting
猜你喜欢

How about the one-stop machine learning opening platform mlflow?
![[Netease Yunxin] in depth analysis of the design of](/img/48/e605357d0eced748c8f644f035052b.png)
[Netease Yunxin] in depth analysis of the design of "circle group" message system | series of articles on "circle group" technology

apache atlas 快速入门

Qt: 访问其他窗体中的控件

Development trend of Web Development

Ultra detailed ffmpeg installation and simple use tutorial

出海企业遇瓶颈 茄子科技(SHAREit Group)有话说
![[NLP] NLP full path learning recommendation](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[NLP] NLP full path learning recommendation

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

Some words from ShareIt group
随机推荐
Site investigation system
【操作教程】如何正确使用海康demo工具配置通道上线?
Shape color gradient, fillet, half fillet, border, fill
10 competitive airpods Pro products worth your choice
High performance practical Alibaba sentinel notes, in-depth restoration of Alibaba micro service high concurrency scheme
Meetup review how Devops & mlops solve the machine learning dilemma in enterprises?
Kotlin练手,以登录为例,Anko简单使用
Neuron Newsletter 2022 - 05 | ajout de 2 entraînements Sud et 1 Application Nord, mise en œuvre de l'extension personnalisée par Modbus TCP
[Huang ah code] I cleaned the console of Google browser in this way
Unity typewriter to automatically roll text to the bottom of the text box
[Netease Yunxin] in depth analysis of the design of "circle group" message system | series of articles on "circle group" technology
移动app性能测试有哪些需要进行?性能测试报告如何收费?
Ultra detailed ffmpeg installation and simple use tutorial
CardView使用及属性
QT database application 22 file coding format recognition
TextInputLayout使用详解
数码管驱动芯片+语音芯片的应用场景介绍,WT588E02B-24SS
学籍管理系统
线性动态规划专讲
CL210OpenStack操作的故障排除--常见核心问题的故障排除