skip to Main Content

I need help with creating image type whatsapp templates. Based on the documentation to create this type of template I need to use the Resumable Upload API.

However, I have not been successful in numerous attempts. I followed the steps to get the key and post the file. I got the hash that the second step of the Resumable Upload API provides. When I pass as a parameter in the json to create the tempate, the return is always an unsupported file format. I’m loading image/png and image/jpeg MIME files. I’m using the Postman tool.

Updated steps

Step 1: Get upload key

https://graph.facebook.com/v14.0/727242995025717/uploads

curl --location --request POST 'https://graph.facebook.com/v14.0/727242995025717/uploads' 
--header 'Authorization: Bearer EAAKVbHRiRzUBAG1HujesBvBuA2ZBbrZAhXuc8aJQVoWhW6IdPeRihH9akMZAyDha5olS4hSXQPSuBZBRVgJA93JLmLQhe0Lz9pXUrxIRXLDzdkwqsReK2UyZBr1YXEMcFYgQUBOlowHlFlWqtXWdJPCGAres7eXtnsqd6nOU4Rqg6B2ZB9e0CnsbOqYhLuZAc70SmtbdjNkagZDZD' 
--header 'Content-Type: text/plain' 
--data-raw '{
    "file_length":"28506",
    "file_type":"image/png",
    "file_name":"test.png"
}

Return:

{
   "id": "upload:MTphdHRhY2htZW50OjgyZWRlNDZhLTA0M2EtNGFkNy04NjNiLTQyNjU0OTAwM2Q4Nj8=?sig=ARYAKCBkBmYa7BkcY_s"
}

Step 2: Post file

curl --location --request POST 'https://graph.facebook.com/v14.0/upload:MTphdHRhY2htZW50OjgyZWRlNDZhLTA0M2EtNGFkNy04NjNiLTQyNjU0OTAwM2Q4Nj8=?sig=ARYAKCBkBmYa7BkcY_s?access_token=EAAKVbHRiRzUBAG1HujesBvBuA2ZBbrZAhXuc8aJQVoWhW6IdPeRihH9akMZAyDha5olS4hSXQPSuBZBRVgJA93JLmLQhe0Lz9pXUrxIRXLDzdkwqsReK2UyZBr1YXEMcFYgQUBOlowHlFlWqtXWdJPCGAres7eXtnsqd6nOU4Rqg6B2ZB9e0CnsbOqYhLuZAc70SmtbdjNkagZDZD' 
--header 'file_offset: 0' 
--header 'Content-Type: multipart/form-data' 
--data-binary '@test.png'

Return:

{
"h":"4:::ARabORl_4eDXWscbjQetu1TN8GWM8042aW6S4gWtDd6wfc0ghJOBiFIdo0iqmQLJTkRr2etuf-U_SfKOSFbNwb-jKvpCR0MEC8hxmkRRHCUq8Q:e:1663677758:727242995025717:100043883327420:ARaa_5q1W1tBJ79gzzk"
}

Step 3: Create the template

curl --location --request POST 'https://graph.facebook.com/v14.0/106148522171805/message_templates' 
--header 'Content-Type: application/json' 
--header 'Authorization: Bearer EAAKVbHRiRzUBAG1HujesBvBuA2ZBbrZAhXuc8aJQVoWhW6IdPeRihH9akMZAyDha5olS4hSXQPSuBZBRVgJA93JLmLQhe0Lz9pXUrxIRXLDzdkwqsReK2UyZBr1YXEMcFYgQUBOlowHlFlWqtXWdJPCGAres7eXtnsqd6nOU4Rqg6B2ZB9e0CnsbOqYhLuZAc70SmtbdjNkagZDZD' 
--data-raw '{
   "name":"template_cliente_importante",
   "components":[
      {
         "type":"HEADER",
         "format":"IMAGE",
         "example":{
            "header_handle":[
                "4:::ARabORl_4eDXWscbjQetu1TN8GWM8042aW6S4gWtDd6wfc0ghJOBiFIdo0iqmQLJTkRr2etuf-U_SfKOSFbNwb-jKvpCR0MEC8hxmkRRHCUq8Q:e:1663677758:727242995025717:100043883327420:ARaa_5q1W1tBJ79gzzk"
            ]
         }
      },
      {
         "type":"BODY",
         "text":"Obrigado por seu contato. Em breve iremos retornar sua solicitacao"
      },
      {
         "type":"FOOTER",
         "text":"Até logo!"
      }
   ],
   "language":"pt_BR",
   "category":"TRANSACTIONAL"
}

Return:

{
    "error": {
        "message": "Invalid parameter",
        "type": "OAuthException",
        "code": 100,
        "error_subcode": 2388084,
        "is_transient": false,
        "error_user_title": "File Type Not Supported",
        "error_user_msg": "The type of file is not supported.",
        "fbtrace_id": "A7sDQpYSaCpWFs6oJgVdt-C"
    }
}

I believe the error is in step 2, I tried several ways of implementation. I can get other types of templates. However media type templates always return an error.

I appreciate everyone’s support!

Tks

2

Answers


  1. Chosen as BEST ANSWER

    problem solved. The error was in Step 1, note that it was passing Content-Type: text/plain. When I switched to Content-Type: application/json. The post worked correctly.

    curl --location --request POST 'https://graph.facebook.com/v14.0/727242995025717/uploads?access_token=EAAKVbHRiRzUBAG1HujesBvBuA2ZBbrZAhXuc8aJQVoWhW6IdPeRihH9akMZAyDha5olS4hSXQPSuBZBRVgJA93JLmLQhe0Lz9pXUrxIRXLDzdkwqsReK2UyZBr1YXEMcFYgQUBOlowHlFlWqtXWdJPCGAres7eXtnsqd6nOU4Rqg6B2ZB9e0CnsbOqYhLuZAc70SmtbdjNkagZDZD' 
    --header 'Content-Type: application/json' 
    --data-raw '{
        "file_length":"28506",
        "file_type":"image/png",
        "file_name":"test.png"
    }
    

    Thanks a lot for the help.

    Hugs


  2. please someone help needed.
    when i perform step 2 above, i get facebook page says Sorry, something went wrong.
    We’re working on it and we’ll get it fixed as soon as we can.
    2 weeks already with that step, i have tried all.
    thank you

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search