【问题标题】:whatsapp cloud api template object issue to send from postman从邮递员发送的 whatsapp 云 api 模板对象问题
【发布时间】:2022-11-30 19:19:58
【问题描述】:

我正在尝试从邮递员发送whatsapp 云模板。 我在 whatsapp 云中创建了一个带有标题媒体图像的模板, 正文内容、页脚和两个按钮。

当我使用 get api 时模板的响应如下

        {
        "name": "trns_btn_img_header_XXX",
        "components": [
            {
                "type": "HEADER",
                "format": "IMAGE",
                "example": {
                    "header_handle": [
                        "https://img.url.com"
                    ]
                }
            },
            {
                "type": "BODY",
                "text": "Body message"
            },
            {
                "type": "FOOTER",
                "text": "ftr optioal"
            },
            {
                "type": "BUTTONS",
                "buttons": [
                    {
                        "type": "QUICK_REPLY",
                        "text": "qrbtnone"
                    },
                    {
                        "type": "QUICK_REPLY",
                        "text": "qrbtntwo"
                    }
                ]
            }
        ],
        "language": "en_US",
        "status": "APPROVED",
        "category": "TRANSACTIONAL",
        "id": "17XX209448XXXXXX"
    }

我试过邮递员中的模板 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"
            }
          }
        ]
      },
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "Body message from pm"
          },         
        ]
      },
      {
        "type": "footer",
        "parameters": [
          {
            "type": "text",
            "text": "footer message from pm"
          },         
        ]
      },
      {
        "type": "button",
        "sub_type": "quick_reply",
        "index": "0",
        "parameters": [
          {
            "type": "text",
            "text": "btnone"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "quick_reply",
        "index": "1",
        "parameters": [
          {
            "type": "text",
            "text": "btntwo"
          }
        ]
      }
    ]
  }
}

响应错误是“错误”:{ “消息”:“(#132000)参数数量与预期的参数数量不匹配”

【问题讨论】:

  • 你能显示正文吗?您是否在正文中添加了任何参数?
  • 我只使用了屏幕中显示的文本,如正文消息,未在云模板中使用“{{}}”

标签: json api cloud whatsapp


【解决方案1】:

确保并更正发送消息端点请求中的以下内容,

  • 不需要通过身体component 如果正文中没有参数,如果有参数,那么您只需要按索引顺序在单独的参数对象中传递该参数文本
  • 不需要通过页脚组件,因为它在您创建模板时是静态的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-17
    • 2014-12-29
    • 2016-12-28
    • 2021-05-19
    • 2022-09-28
    • 1970-01-01
    • 1970-01-01
    • 2018-07-12
    相关资源
    最近更新 更多