当前位置:网站首页>[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service
[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service
2022-06-10 13:04:00 【51CTO】
Huawei Sports health services (HUAWEI Health Kit) It provides for the tripartite ecological application REST API Interface , The database can be accessed through its interface , Provide users with sports and health data services . In the actual integration process , Developers may encounter various problems , Here we will share and summarize the typical problems , Hope to provide reference for other developers who encounter similar problems .
1. After registering the subscription notification capability , Connectivity check failed
After registering as a subscriber , When testing the connectivity check callback notification address , Tips “ Connectivity check failed , Connectivity check response is not 204”.
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ data](https://s9.51cto.com/images/blog/202206/10092907_62a29e63cc3a127958.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
Cause analysis :
When the callback notification address is accessible , The developer needs to confirm the callback notification address of the subscription HTTP Whether the status code is 204, Otherwise it will return 404 Indicates that the callback address connectivity check failed . Reference resources Subscribe to data documents
Solution :
Check if the link is available , And whether the returned status code is 204.
2. The total number of steps returned by the sampling data statistics interface is inconsistent with the total number calculated by yourself after obtaining the step number detail data
use Sampling data statistics Query the interface to get the total number of steps
Statistical query interface :https://health-api.cloud.huawei.com/healthkit/v1/sampleSet:polymerize Request parameters :
The final returned number of steps is 7118
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ developer _02](https://s4.51cto.com/images/blog/202206/10092907_62a29e63c7ea171876.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
use Sampling data details Query the interface to get the step details , And calculate the sum
Details query interface :https://health-api.cloud.huawei.com/healthkit/v1/sampleSet:polymerize Request parameters :
The total number of steps calculated according to the returned results is 6280  【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ developer _03](/img/91/b12f835d762960f7d4461724f39afb.png)
We can see from the data that , On the premise of the same time period , The total number of steps returned by the sampling data statistics interface is inconsistent with the total number calculated according to the step number details .
Cause analysis :
It is caused by different mechanisms between detailed data and statistical data . Detailed data and statistical data are reported separately , For various reasons , Details may be lost or delayed , As a result, the two kinds of data can not be exactly matched . secondly , When counting the data of a day , When the aggregation condition is the following parameters ( See the picture below ), The returned statistics are reported , Instead of data calculated through detailed data .  【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ developer _04](/img/4e/4f0c186840c3f47d2626c85cce3b90.png)
Solution :
Sampling data statistics query , Aggregate by time , Pass in groupByTime Parameters ,groupByTime Set in duration Parameters . Request parameters :
The final result is 6280, Consistent with the sum calculated according to the step details .
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ developer _05](/img/ae/1bc171dfc67329736b40008df2224d.png)
3. Error code 403, error message “Insufficient Permission: Request had insufficient authentication scopes.”
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ data _06](/img/4a/6d9d418e66733b5f3d11e88c8fcd28.png)
Cause analysis :
403 To reject a request , Mainly scopes Insufficient authority , Cause the request to be rejected .
Solution :
(1) Check whether the alliance card has applied for relevant permissions .
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ developer _07](/img/96/a5d98c8675f89cf0499bd2d3ed3f7f.png)
(2) Check whether the requested permission is passed in during authentication , And whether consent authorization has been made on the authorization page .  【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ data _08](https://s3.51cto.com/images/blog/202206/10092907_62a29e63d6c1a60547.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
Whether the requested permission is passed in during authentication Whether permission is checked in the authorization interface
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ data _09](/img/73/c6c4c0d92e5adb2e831ea4a0290ee9.jpg)
4. Error code 400, error message “Insufficient Permission: Request had insufficient authentication scopes.”
Case study : Query the sampling data details of steps Parameter description : Access Token: Based on the first authentication code Code generation . The time of the first authentication ( For the first time code Code time ):2022 year 5 month 7 The morning of 8 P.m. . Start time of data collection : Starting time :2022-05-06 00:00:00(1651766400000) End time :2022-05-06 12:00:00(1651809600000) Specific request , See the picture below :
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ Solution _10](/img/17/360eb6e85bddd145006c677665aa5a.png)
In response to the results :
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ Solution _11](https://s8.51cto.com/images/blog/202206/10092907_62a29e63ddbde74398.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
Cause analysis :
When querying data , For the protection of user data , Only developers are allowed to query data after user authorization . If you need to query the data before user authorization , Developers need to get “ Read historical data ” Authorization of authority , If the user does not grant this permission , If the start time set by the developer when querying data is earlier than the user authorization time , The start time will be automatically corrected to the time when the user first authorizes , This will result in query errors (code:400,message: “Invalid startTime or endTime.”) Or you can only query the data after the user authorization time , Inconsistent with the set start time . Take the example in the question , Because the user did not grant “ Read historical data ” Authority , At the start time 5 month 6 Japan , The first authorization time is 5 month 7 In the case of , The start time will be automatically corrected to the first authorization time , That is to say 5 month 7 Japan , This causes the corrected start time to be later than the end time , Therefore, the error code is returned 400, error message "Invalid startTime or endTime.".
Solution :
(1) Check Health Kit Whether the League card has applied for “ Read historical data ” jurisdiction , This permission is visible in the server application
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ Solution _12](https://s5.51cto.com/images/blog/202206/10092907_62a29e63d17f435597.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
(2) Generate authorization code code when , stay scope Add "https://www.huawei.com/healthkit/historydata.open" jurisdiction , The user can grant... To the application after logging in to the Huawei account “ Read historical data ”. Data queried after authorization :
 【FAQ】 Sports health services REST API Summary of common problems and solutions during interface use _ Solution _13](https://s6.51cto.com/images/blog/202206/10092907_62a29e63d874549469.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
Learn more >> visit The official website of Huawei Sports Health Service Alliance
visit Huawei sports health scenario solution
obtain Huawei sports health service development guidance document
边栏推荐
- Program, calculate 2/1+3/2+5/3+8/5 Value of. It is required to calculate the sum of the first n items and keep 2 decimal places (starting from the second item of the sequence, the numerator of each it
- Count the number and average value of natural numbers whose sum of bits within 100 is 7
- 好文分享|48小时敏捷开发攻略
- MySQL service evolution
- If the files and graphics are lost, it means that you don't need the office developed by yourself
- IQR box diagram
- Leetcode 96. Différents arbres de recherche binaires
- DynaSLAM II: Tightly-Coupled Multi-Object Tracking and SLAM 论文阅读
- VDMA调试总结
- excel异步导出
猜你喜欢
![[spark] (task8) pipeline channel establishment in sparkml](/img/9c/69c6d0cb27906eb895cfc7e4f45f96.png)
[spark] (task8) pipeline channel establishment in sparkml

20-year technical veteran gives up his CTO title! Why did the startup attract him?

Don't mistake "it informatization" for "super project"

TIDB 初级课程体验 8 (集群的管理维护, 添加一个TIKV节点)

谷歌提出超强预训练模型CoCa,在ImageNet上微调Top-1准确率达91%!在多个下游任务上SOTA!

深度神经网络每秒分类近20亿张图像,新型类脑光学分类器芯片登上Nature

Start with interpreting the code automatically generated by BDC, and explain the trial version of the program components of sapgui

IQR箱线图

【FLinlk】Flink小坑之kerberos动态认证

文档提升计划第二期|OceanBase 邀您一起进行文档共建
随机推荐
Software project management 6.10 Cost budget
VDO-SLAM源码阅读笔记[1] Track()中动态obj部分
【Spark】(task8)SparkML中的pipeline通道建立
'getcolor (int) 'is deprecated, getcolor is obsolete
CVPR2022|AConvNetforthe2020s&如何设计神经网络总结
Baidu programmers were sentenced to nine months for deleting the database. The one click unbinding function of the mobile phone number was released. Twitter compromised with musk again. Today, more bi
[raise bar C #] how to call the base of the interface
启牛能开户吗,在启牛开户安全么
统计100以内的各位数之和为7的自然数的个数及平均值
SparkStreaming实时数仓 问题&回答
由文件图形丢失,说明自己都不用自己开发的OFFICE
向数据库中注册用户名和密码的功能
深度神经网络每秒分类近20亿张图像,新型类脑光学分类器芯片登上Nature
【Golang】创建有配置参数的结构体时,可选参数应该怎么传?
好文分享|48小时敏捷开发攻略
C # balanced weight distribution
colmap源码阅读笔记[1] threading.cc
Tidb elementary course experience 8 (cluster management and maintenance, adding a tikv node)
Count the number and average value of natural numbers whose sum of bits within 100 is 7
Leetcode 96. Different binary search trees