wolfgang
wolfgang

Reputation: 7809

Facebook Messenger API - 400 Bad Request?

This is the full JSON below, I'm sending using Facebook's Generic Template.

I've checked it line-by-line with the official documentation here -> https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template

But I'm getting a 400 Bad Request Error for the following. What am i missing?

{  
   "recipient":{  
      "id":"1347939335300515"
   },
   "message":{  
      "attachment":{  
         "type":"template",
         "payload":{  
            "template_type":"generic",
            "elements":[  
               {  
                  "title":"Welcome to Peters Hats",
                  "image_url":"https://cdn.pixabay.com/photo/2013/07/13/10/41/hat-157581_960_720.png",
                  "subtitle":"Weve got the right hat for everyone.",
                  "default_action":{  
                     "type":"web_url",
                     "url":"https://cdn.pixabay.com/photo/2013/07/13/10/41/hat-157581_960_720.png",
                     "messenger_extensions":true,
                     "webview_height_ratio":"tall",
                     "fallback_url":"https://cdn.pixabay.com/photo/2013/07/13/10/41/hat-157581_960_720.png"
                  },
                  "buttons":[  
                     {  
                        "type":"web_url",
                        "url":"https://cdn.pixabay.com/photo/2013/07/13/10/41/hat-157581_960_720.png",
                        "title":"View Website"
                     },
                     {  
                        "type":"postback",
                        "title":"Start Chatting",
                        "payload":"DEVELOPER_DEFINED_PAYLOAD"
                     }
                  ]
               }
            ]
         }
      }
   }
}

Upvotes: 0

Views: 1229

Answers (1)

wolfgang
wolfgang

Reputation: 7809

The default_action is a URL Button and not supposed to be a postback button as in the JSON posted in the question.

Upvotes: 0

Related Questions