Why the Meta Webhook api isn't working properly?
I'm working on an api that receives notifications from the meta weebhook every time my page have changes. Currently its in test mode, I just want to test the webhook first. In the process I'm able to verify my callback link but once I want to test one of the fields nothing its send to my server. Feed field that I want to test I have a POST controller in my backend that should take care of the request and its working; How do I know that ? Because one of the only fields that sends a request it send_cart field. Send cart field There is one or two more fields that actually send a request, but 98% of them don't work. Im not sure if there an error on the Meta Graph API or I did something wrong. If anyone had this problem, or has an idea how I could solve it, it would be very helpful; because this should have been a simple project but it's taking me a week, and I'm already embarrassed. If more information its needed I'm gonna be responding all the requests. Thanks ! Below its the server code that I'm working with:
- This is the controller:
exports.facebookWebhook = (req, res) => { if(req.query["hub.verify_token"] === "my_token"){ res.status(200).send(req.query["hub.challenge"]) }else{ res.status(400).send({ message: "bad request" }) } } exports.facebookWebhookChanges = (req, res) => { if (!req.body || Object.keys(req.body).length === 0) { console.log('Received an empty request body'); res.status(400).send('Bad Request: Request body is empty'); return; } console.log(req.body) res.status(200).send({ message: "Ok" }) }
- This is the route:
app.get("/api/facebook/webhook/", controller.facebookWebhook); app.post("/api/facebook/webhook/", controller.facebookWebhookChanges);
I already read all the documentation to make sure Im doing everything good, I have read other people posts that doesnt match with my problem. I asked on facebook developer forum to.