Sending Template message with image

Mohamed Hussein 610 Reputation points
2025-01-20T20:15:43.4766667+00:00

Good Day,

At WhatsApp advanced messaging

Is that possible to send template message including image at header supported?


  messaging_client = NotificationMessagesClient.from_connection_string(connection_string)
    channelRegistrationId = "1ea07df4-9843-438b-887e-d8891ba4a201"
    phone_number = "xxxxx"

    # Template Name bulk_azure_insta_ar 
    input_template: MessageTemplate = MessageTemplate(
    name="bulk_promo",
    language="ar")
    template_options = TemplateNotificationContent(
    channel_registration_id=channelRegistrationId,
    to=[phone_number],
    template=input_template
    )

System.Private.CoreLib: Exception while executing function: Functions.HusAzFuncBulkSend. System.Private.CoreLib: Result: Failure
Exception: HttpResponseError: (BadRequest) Given request contains a parameter for WhatsApp which was invalid. This includes channel ID and template parameters.
Code: BadRequest
Message: Given request contains a parameter for WhatsApp which was invalid. This includes channel ID and template parameters.
Inner error: {
    "code": "WhatsAppAdminClient+WaErrorCode.InvalidParameter",
    "message": "InvalidParameter: (#132012) Parameter format does not match format in the created template. header: Format mismatch, expected IMAGE, received UNKNOWN"
}
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
980 questions
{count} votes

Accepted answer
  1. Shree Hima Bindu Maganti 2,415 Reputation points Microsoft Vendor
    2025-01-21T02:30:15.8533333+00:00

    Hi
    Welcome to the Microsoft Q&A Platform!Welcome to the Microsoft Q&A Platform! The error indicates that the template message for WhatsApp has a format mismatch issue, specifically in the header. It expects an IMAGE format in the template's header but is receiving an UNKNOWN format.

    • Navigate to Meta Business Manager > WhatsApp > Message Templates.
    • Ensure the header type is set to Image.
    • Confirm that placeholders in the template match the parameters being sent.
    • Add the header image URL to the API request.
    • The image must be publicly accessible (e.g., https://example.com/image.jpg). update the code,
        from azure.communication.notification_hubs import NotificationMessagesClient, TemplateNotificationContent, MessageTemplate
        messaging_client = NotificationMessagesClient.from_connection_string(connection_string)
        input_template = MessageTemplate(name="bulk_promo", language="ar")
        template_options = TemplateNotificationContent(
          channel_registration_id="1ea07df4-9843-438b-887e-d8891ba4a201",
          to=["xxxxx"],
          template=input_template,
          media={"header": {"type": "image", "url": "https://example.com/image.jpg"}}
        )
        response = messaging_client.send(template_options)
        print(response)
      
    • Confirm it matches the template’s expected type (Image).
    • Ensure the URL is accessible.
    • Double-check the parameters passed in the API.
    • Test sending the template directly via Meta Business Manager.
    • Validate all credentials: connection_string, channel_registration_id, and phone number.
      Analyze logs for additional details if issues persist. ref:https://learn.microsoft.com/en-us/azure/notification-hubs/
      https://developers.facebook.com/docs/whatsapp
      If the answer is helpful, please click Accept Answer and kindly upvote it
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.