postmanwhatsappwhatsapiwhatsapp-cloud-api

header: Format mismatch error while sending template message in WhatsaApp API using Postman


I am trying to solve the mystery of the code below. I wrote the code regarding the meta documentation for sending template messages. Everytime I try to send message I am getting an error message like below

{
    "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 DOCUMENT, received UNKNOWN"
        },
        "fbtrace_id": "A3xxC_8Mj0HOPgQhvFpdCOa"
    }
}

I'm using the following snippet:

{
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "{{Recipient-Phone-Number}}",
    "type": "template",
    "template": {
        "name": "test_temp",
        "language": {
            "code": "en_US"
        }
    },
    "components": [
        {
            "type": "header",
            "parameters": [
                {
                    "type": "document",
                    "document": {
                        "filename": "Purchase Note - 123456789.pdf",
                        "link": "https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf"
                    }
                }
            ]
        },
        {
            "type": "body",
            "parameters": [
                {
                    "type": "text",
                    "text": "123456789"
                }
            ]
        }
    ]
}

I don't understand what is the problem with my code I tried lots of methods to alter my code but nothing worked. Please help me to resolve this issue.

I tried using ID instead of link, still the code is not working


Solution

  • The structure of the provided JSON is incorrect, components should be be inside "template" : {}

    Reference


    You can adjust your template to the following:

        {
        "messaging_product": "whatsapp",
        "recipient_type": "individual",
        "to": "{{Recipient-Phone-Number}}",
        "type": "template",
        "template": {
            "name": "test_temp",
            "language": {
                "code": "en_US"
            },
            "components": [
                {
                    "type": "header",
                    "parameters": [
                        {
                            "type": "document",
                            "document": {
                                "filename": "Purchase Note - 123456789.pdf",
                                "link": "https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf"
                            }
                        }
                    ]
                },
                {
                    "type": "body",
                    "parameters": [
                        {
                            "type": "text",
                            "text": "123456789"
                        }
                    ]
                }
            ]
        }
    }