Help Needed with receiving webhooks

Hi all,

I apologize for the newbie question as I’m very new to all this. I’m extending the getting-started examples for creating a simple connected app. I tried to register a simple webhook on issue:create. I can see a post event happening when I create an issue in Jira, but it seems I can’t handle it in my route.

my webhook is very simple:
“webhooks” : [
{ “event” : “jira:issue_created”,
“url” : “/issue_created” }
]

on my index.js, I was simply trying to do a console.log that I receive it.

app.post(’/issue_created’, addon.authenticate(), function(req, res) {
console.log(“webhook called”);
});

I was never able to see my console comment. It’s like my route was never triggered. Please help.

Hi @DatWebb,

I’ve tried to set up an app similar to yours.
Here’s my modules field in application descriptor which defines the webhook:

"modules": {
        "webhooks": [
            {
                "event": "jira:issue_created",
                "url": "/issue_created",
                "excludeBody": false
            }
        ]
    }

Here is my route, it’s a little bit different in that I’m using res.status(204).send() to return 204 No Content response. It shouldn’t matter in your case but it is a good practice to do that.

app.post('/issue_created', addon.authenticate(), (req, res) => {
        console.log("Webhook arrived.");
        res.status(204).send(); //you should always return a response after handling the request
    });

And here is a part of my output from the console:

POST /installed 204 27.729 ms - -
Registered with host at https://<redacted>.atlassian.net/
Webhook arrived.
POST /issue_created?lic=none 204 6.046 ms - -

How did I trigger my webhook? First I used npm start to start up and install the application on my Jira instance then I went to my project and created an issue which triggered a webhook.

To me, your configuration looks fine and it should work but just to be sure could you please try to run it with my configuration and confirm if the issue persists?

Cheers,
Maciej

1 Like

@MaciejStanuch Thank you for your response! Things seems to be working now. I think my initial issue is that I didn’t do a rebuild before I restart. I think that’s why my console.log statement didn’t register. Thank you for your help!