Webhook not able to connect to a functioning API

Hi all,

I created a simple Express app running on my local network with functioning API endpoints that I’ve tested with multiple other tools. For some reason, when I try to connect my webhook to this app, I receive the “Failed to communicate with the URL provided” error and I cannot figure out why.

I’ve constructed my http POST exactly as it is shown on the Webhook integration support article, but this has not helped.

Here is the code for my express app (as I’ve mentioned, these endpoints work just fine with everything else):

const express = require('express');
const app = express();
const port = 2020;

app.get('/', (req, res) => {
    res.send("success");
})

app.post('/', (req, res) => {
    console.log(JSON.stringify(req.body, 0, 2));
    res.status(200).send(req.body);
})

app.listen(port, () => {
    console.log(`App listening on port ${port}`)
})

I figured this out- my problems were:

  • I was not tunneling my localhost app, this is required for the webhook to be able to interact with the application. Install ngrok, and then on the same port through which you’re running your application, run the command
    ngrok http {port}
    ngrok will then provide you with a forwarding URL, which is the url that you provide to the webhook as if it were your endpoint. In other words, myapi.com/data would be given to the webhook as {ngrok forward url}/data

  • I was not parsing the response as JSON, which prevented me from interacting with it at all. I fixed this by adding the following line of code to my Express app, which tells express to parse a request using JSON: app.use(express.json())