Unable to sent message through WhatsApp Business API
I am trying to send WhatsApp message, using WhatsApp Business API and GraphQL.
But I am getting this error:
Failed to send message to : { "error":{ "message":"(#132012) Parameter format does not match format in the created template", "type":"OAuthException", "code":132012, "error_data": { "messaging_product":"whatsapp", "details":"header: Format mismatch, expected IMAGE, received UNKNOWN" }, "fbtrace_id":"AyPLLsvyikPmg66DWF_ZfYU" } }
This is the code I have written. And also I am sharing the message structure.
import requests import openpyxl access_token = "" template_name = "healthy_sports_b2s_2" # Replace with your template name language_code = "en" wb = openpyxl.load_workbook("numbers.xlsx") sheet = wb.active for row in sheet.iter_rows(min_row=2, values_only=True): customer_number = row[0] url = f"https://graph.facebook.com/v17.0/XXXXXXXXXXXXXXX/messages" headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/json", } message_payload = { "messaging_product": "whatsapp", "to": customer_number, "type": "template", "template": {"name": template_name, "language": {"code": language_code}}, "components": [ { "parameters": [ { "type": "template", "image": { "link": "https://res.cloudinary.com/dapnrioqr/image/upload/v1691648851/02_wgucrp.jpg" }, } ] } ], } response = requests.post(url, json=message_payload, headers=headers) if response.status_code == 200: print(f"Message sent to {customer_number}") else: print(f"Failed to send message to {customer_number}: {response.text}")
What can I do to solve this