You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Fit API添加营养数据报Mismatched value count错误排查

解决Google Fit API添加营养数据时的"Mismatched value count" 400错误

错误含义

该400(INVALID_ARGUMENT)错误的核心是营养数据点的value数组元素数量不符合要求。Google Fit的com.google.nutrition数据类型规定,每个数据点仅允许包含一个mapVal类型的value对象,用来封装所有营养成分的键值对。你的请求payload中,value数组里除了正确的mapVal对象,还额外添加了一个intVal:4的元素,导致API检测到两个value,触发了"值数量不匹配"的校验失败。

修复方法

直接删除value数组中多余的{ "intVal": 4 }元素,仅保留包含营养成分键值对的mapVal对象即可。

修正后的完整请求Payload

{
  "minStartTimeNs": 1624323600000000000,
  "maxEndTimeNs": 1624327200000000000,
  "dataSourceId": "my-datasource-id",
  "point": [
    {
      "startTimeNanos": 1624323600000000000,
      "endTimeNanos": 1624327200000000000,
      "dataTypeName": "com.google.nutrition",
      "value": [
        {
          "mapVal": [
            {
              "key": "calories",
              "value": {
                "fpVal": 456.7
              }
            },
            {
              "key": "fat.total",
              "value": {
                "fpVal": 20.7
              }
            },
            {
              "key": "fat.saturated",
              "value": {
                "fpVal": 11.3
              }
            },
            {
              "key": "fat.polyunsaturated",
              "value": {
                "fpVal": 0
              }
            },
            {
              "key": "fat.monounsaturated",
              "value": {
                "fpVal": 0
              }
            },
            {
              "key": "fat.trans",
              "value": {
                "fpVal": 0
              }
            },
            {
              "key": "cholesterol",
              "value": {
                "fpVal": 90
              }
            },
            {
              "key": "sodium",
              "value": {
                "fpVal": 753.3
              }
            },
            {
              "key": "potassium",
              "value": {
                "fpVal": 0
              }
            },
            {
              "key": "carbs.total",
              "value": {
                "fpVal": 32
              }
            },
            {
              "key": "dietary_fiber",
              "value": {
                "fpVal": 2.7
              }
            },
            {
              "key": "sugar",
              "value": {
                "fpVal": 2
              }
            },
            {
              "key": "protein",
              "value": {
                "fpVal": 30.7
              }
            }
          ]
        }
      ]
    }
  ]
}

内容的提问来源于stack exchange,提问作者Matt McCormick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 18:05:55