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

通过Postman发送WhatsApp Cloud API模板时遇参数不匹配报错

WhatsApp Cloud API模板请求参数不匹配问题解决

问题原因

你创建的模板中,正文(BODY)、页脚(FOOTER)、快速回复按钮都是固定文本,没有设置{{1}}这类变量占位符,但你在Postman请求里给这些组件都添加了parameters参数,导致实际传递的参数数量和模板预期的参数数量不匹配,触发了(#132000) Number of parameters does not match the expected number of params错误。

只有模板组件包含变量占位符时,才需要在请求中传递对应参数;固定内容的组件不需要传任何参数。

修正后的请求JSON

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "{{message_to}}",
  "type": "template",
  "template": {
    "name": "trns_btn_img_header_XXX",
    "language": {
      "code": "en_US"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "link": "https://img.jpg.com"
            }
          }
        ]
      }
      // 正文、页脚、按钮为固定内容,无需传递参数,可直接省略这些组件
    ]
  }
}

如果要明确保留所有组件结构(仅传递必要参数),也可以这么写:

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "{{message_to}}",
  "type": "template",
  "template": {
    "name": "trns_btn_img_header_XXX",
    "language": {
      "code": "en_US"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "link": "https://img.jpg.com"
            }
          }
        ]
      },
      {
        "type": "body"
      },
      {
        "type": "footer"
      },
      {
        "type": "buttons",
        "buttons": [
          {
            "type": "quick_reply"
          },
          {
            "type": "quick_reply"
          }
        ]
      }
    ]
  }
}

关键注意事项

  • 图片头部是唯一需要传参数的部分,因为模板定义的是IMAGE格式的HEADER,必须提供实际图片地址。
  • 固定内容的组件(BODY、FOOTER、快速回复按钮),请求中不能传递parameters,也无法修改模板里的固定文本——模板审核通过后,固定内容只能使用原始定义。
  • 快速回复按钮需要包裹在type: "buttons"的组件下,和模板的结构保持一致,不能拆成单独的type: "button"组件。

内容的提问来源于stack exchange,提问作者vijay kumar

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 08:50:25