简体   繁体   English

Withings API 机身样品

[英]Withings API Body Sample

I'm trying to get data back from this Withings endpoint: https://developer.withings.com/api-reference/#operation/measure-getmeas我正在尝试从 Withings 端点取回数据: https://developer.withings.com/api-reference/#operation/measure-getmeas

But every combination of things I've tried simply returns:但是我尝试过的每一种组合都会简单地返回:

status body error状态正文错误


503 Invalid Params 503 无效参数

This is the most recent body that isn't working: action=getmeas&meastype=meastype&meastypes=11&category=1&startdate=1641168000&enddate=1641254399这是最新的不工作的机构:action=getmeas&meastype=meastype&meastypes=11&category=1&startdate=1641168000&enddate=1641254399

For reference: https://developer.withings.com/api-reference/#operation/measure-getmeas供参考: https://developer.withings.com/api-reference/#operation/measure-getmeas

Based on what you posted, the problem is your parameter meastype=meastype .根据您发布的内容,问题在于您的参数meastype=meastype If you remove this then it should run fine.如果您删除它,那么它应该运行良好。

Assuming you have followed the procedure to get an access token your call from PowerShell would look like this:假设您已按照程序获取访问令牌,您从 PowerShell 的呼叫将如下所示:

Invoke-RestMethod -Method 'Post' -Headers @{ "Authorization" = "Bearer XXXXXXXXXXXXXXXXXX" } -Body "action=getmeas&meastypes=11&category=1&startdate=1641168000&enddate=1641254399" -Uri 'https://wbsapi.withings.net/measure'

This will return a JSON structure as per the docs you link to in the question eg根据您在问题中链接到的文档,这将返回 JSON 结构,例如

{
  "status": 0,
  "body": {
    "updatetime": "string",
    "timezone": "string",
    "measuregrps": [
      {
        "grpid": 12,
        "attrib": 1,
        "date": 1594245600,
        "created": 1594246600,
        "category": 1594257200,
        "deviceid": "892359876fd8805ac45bab078c4828692f0276b1",
        "measures": [
          {
            "value": 65750,
            "type": 1,
            "unit": -3,
            "algo": 3425,
            "fm": 1,
            "fw": 1000
          }
        ],
        "comment": "A measurement comment"
      }
    ],
    "more": 0,
    "offset": 0
  }
}

If your "measuregrps" is empty (like mine is below) then it means there is no data available for the time period you selected so either your device doesn't record that parameter or the data has not been synchronised to your Withings account.如果您的“measuregrps”为空(如下所示),则表示您选择的时间段内没有可用数据,因此您的设备未记录该参数或数据未同步到您的 Withings 帐户。

What I get when I run it (my device doesn't record HR):我运行它时得到的结果(我的设备没有记录 HR):

status body
------ ----
     0 @{updatetime=1641470158; timezone=Europe/London; measuregrps=System.Object[]}

Another option is to use Windows Subsystem for Linux to run curl commands.另一种选择是使用 Linux 的 Windows 子系统来运行 curl 命令。 You essentially get the same thing:你基本上得到了同样的东西:

curl --header "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXX" --data "action=getmeas&meastype=11&category=1&startdate=1609925332&enddate=1641461360" 'https://wbsapi.withings.net/measure'

gives

{
    "status":0,
    "body":{
        "updatetime":1641470640,
        "timezone":"Europe\/London",
        "measuregrps":[]
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM