使用WhatsApp API发送带模板文档时遇参数格式错误求助
排查WhatsApp API模板文档发送的手机号格式错误
错误信息
{ "error": { "message": "(#100) Invalid parameter", "type": "OAuthException", "code": 100, "error_data": { "messaging_product": "whatsapp", "details": "For component HEADER, parameter '' does not have a valid phone_number format. Length Limit is 20 characters and detailed format requirements can be found in official documentation." }, "fbtrace_id": "AMpCyBYnc9ch7Ivdzk6sJ6S" } }
请求体配置
{ "messaging_product":"whatsapp", "to":"{{Recipient-Number}}", "type":"template", "template":{ "name":"docs", "language":{ "code":"fr" }, "components":[ { "type":"header", "parameters":[ { "type":"document", "document":{ "link":"https://pdfobject.com/pdf/sample.pdf" } } ] }, { "type":"body", "parameters":[ { "type":"text", "text":"credit CS" }, { "type":"text", "text":"Mutual" }, { "type":"text", "text":"reçu" } ] } ] } }
错误原因
你在Meta后台创建的docs模板,其HEADER组件的参数类型与请求体中传递的类型不匹配。错误提示指向“空参数不符合手机号格式”,说明模板的HEADER参数被定义为手机号类型,但你请求中传递的是document类型,导致API校验时无法正确解析参数,进而抛出格式错误。
解决方法
- 登录Meta Business Manager,进入对应WhatsApp账号的模板管理页面,找到
docs模板 - 检查HEADER组件的参数配置:如果模板HEADER设置了手机号参数,将其修改为文档类型;如果不需要该参数,直接删除,确保模板HEADER的参数类型与请求体中传递的
document完全一致 - 若修改了模板,需重新提交并等待Meta审核通过
- 再次发送请求,确认参数类型与模板定义匹配
内容的提问来源于stack exchange,提问作者Illiassou Icy
相关产品推荐
相关产品推荐

