I created below template in Whatsapp API. And I want to set the parameter value in the API call. What is the correct payload ? I have been following the Meta docs and trying but every time I get error. Please Help.
Template:
You order # {{1}} is received successfully.

I used this payload:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
But I am still getting this error
{
"error": {
"message": "(#132000) Number of parameters does not match the expected number of params",
"type": "OAuthException",
"code": 132000,
"error_data": {
"messaging_product": "whatsapp",
"details": "body: number of localizable_params (0) does not match the expected number of params (1)"
},
"error_subcode": 2494002,
"fbtrace_id": "AzPa-uWXctIcdNVu0Lf3Fic"
}
}
The issue due to closing the template object then opening a new component object. make the component object inside the template object and it will be fixed
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
}
I just want to add to the right answer of Hisham A, that if you have more than one param/variable as I did you just have to add as many elements to the component as params.
In my case (sorry text being in portuguese):
For the mensage body:
Reserva de {{1}} para o(s) dia(s) {{2}} de {{3}} para a carrinha {{4}}.
The json data:
{
"messaging_product": "whatsapp",
"to": "351934566644",
"type": "template",
"template": {
"name": "reserva_feita_teste",
"language": { "code": "pt_PT" },
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Sofia"
},
{
"type": "text",
"text": "1, 2, 3"
},
{
"type": "text",
"text": "janeiro"
},
{
"type": "text",
"text": "Grande Nova"
}
]
}
]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With