Skip to main content

I have an unbuntu server running apache with virtual directories.  I’m getting the following  error when I attempt to register a webhook:  Failed to create subscription: WebHook responds with incorrect HTTP status. HTTP status is 404.  

The code that is rendering this error is: 

async function createSubscription() {
try {
let response = await platform.post('/restapi/v1.0/subscription', {
eventFilters: F
"/restapi/v1.0/account/~/extension/~/telephony/sessions"
],
deliveryMode: {
transportType: "WebHook",
address: process.env.WEBHOOK_URL
}
});
console.log("Subscription created:", response.data);
} catch (error) {
console.error("Failed to create subscription:", error.message);
}
}

 

You should make sure that your webhook endpoint is publicly accessible. You must also make sure that you capture the ‘validation-token’ and return it in the header within 3 secs. In Node JS code, it looks like this.

if(req.headers.hasOwnProperty("validation-token")) {
res.setHeader('Validation-Token', req.headersd'validation-token']);
res.statusCode = 200;
res.end();
}else{
// read the event data
}

 


Reply