尝试从Google Fit获取GET来读取Google睡眠数据的API,但返回400错误的请求作为回应

问题描述

以下是我在Google Playground上传递的请求,并尝试通过代码获取Access令牌和其他数据。这里使用的范围:https://www.googleapis.com/auth/fitness.activity.read

GET /fitness/v1/users/me/sessions?startTime=2019-12-05T00:00.000Z&endTime=2019-12-17T23:59:59.999Z&activityType=72 HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer Auth_code

解决方法

您的开始时间格式不正确:

static

您需要几小时,几分钟和几秒钟:

startTime=2019-12-05T00:00.000Z

在OAuth运动场中的请求:

startTime=2019-12-05T00:00:00.000Z

响应:

GET /fitness/v1/users/me/sessions?startTime=2019-12-05T00:00:00.000Z&endTime=2019-12-17T23:59:59.999Z&activityType=72 HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: ...

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...