Jira Cloud WebHook

Hello everyone.
I am new to the world of Jira and ran into an insurmountable problem.
I would like to register a webhook that sent notifications to a created subpage of jira applications or to an external api. I use atlassian connect express and initially wanted to register the webhook in the descriptor, but from this level it only displayed information about the event in cmd …
I care about complete information about the events that the webhook would handle and send to the additional w JIRA card created by the applikations or to an external api.
Would someone be able to lead me by the hand through this? Either I post a code that I can learn from or just fix my problem.

Thank you in advance for your response

I think there is not enough info in your post. Would be good to post at least some code or write which webhooks you are trying to use.
Generally the webhooks send information only to your backend, so code that process the webhook should be there.

In my project it looks like this
In atlassian-connect.json I have code like this:

"modules": {
        "webhooks": [
            {
                "event": "jira:issue_updated",
                "url": "/issue_updated"
            },
            {
                "event": "jira:issue_created",
                "url": "/issue_created"
            },
            {
                "event": "jira:issue_deleted",
                "url": "/issue_deleted"
            }
        ]
    }

On the server side there are following endpoints declared:

app.post('/issue_updated', addon.authenticate(true), function (req, res) {
    console.log("issue_updated body: " + JSON.stringify(req.body));
    res.sendStatus(204);
  });
  app.post('/issue_created', addon.authenticate(true), function (req, res) {
    console.log(`Issue created. Issue key:${req.body.issue.key}, client:${req.context.clientKey}.`);
    res.sendStatus(204);
  });
  app.post('/issue_deleted', addon.authenticate(true), function (req, res) {
    console.log(`Issue deleted. Issue key:${req.body.issue.key}, client:${req.context.clientKey}.`);
    res.sendStatus(204);
  });

In the server code I ony use console log to show what retrieved. My app is processing the data as it needs. You need to process it as you need.
Hope this helps.

1 Like

I create new page on jira and want to receve and show whats going on my website (via API) - i mean that new issues are created, updated etc. As via the administration panel - we set what events are to be sent to a specific URL.
The intention is that all the time while the application is running, webhooks with actions that will happen during this time - on a regular basis

[image]
-I started with the installation of the basic ACE application.
-I add webhooks to the Modules:
image
-Set Scopes to READ
-I started it and only when it was able to send the webhook is when I restart the application.

I also tried other ways …
(Will send in next comment - limits)

But somehow it doesn’t work for me - I must have made mistakes that eyes hurt.

To check if webhooks are received, I used:

Thank you for your reply :]

Hi @PiotrStaro,

welcome to the Atlassian Developer Community!

I think that the reason why your webhook registered via descriptor is not delivered is a mismatch between app base url and the url where the webhook is sent.

That requirement is documented on that page, however it can be easily missed out.

Specifies your add-on’s POST webhook handler URL. This property must be a URL relative to the add-on’s baseUrl.

To solve the issue, I recommend to implement an easy endpoint in your app that will proxy the webhook to Pipedream.

The only thing that makes me confused it that you said that some webhooks were delivered. Can you elaborate on that case?

started it and only when it was able to send the webhook is when I restart the application .

Regards,
Beata

3 Likes

Hello @BeataSzturemska ,
About https://developer.atlassian.com/cloud/jira/platform/modules/webhook/ - could you send me some examples of using this ? Because i didnt get it … and the “Recipe” is missing.
How to imprement endpoint in my code ?

“The only thing that makes me confused it that you said that some webhooks were delivered. Can you elaborate on that case?”
Yes thats true - When the application works and i create an event, the webhook with the delayed data is sent when restarting and restarting.

Since you are using atlassian connect express, I’m assuming you did generate the basic project files etc. If yes, then you should have something like routes/index.js file. Inside it there are already some end points if I remember correctly: something like app.get(…). Add your endpoints there.
I’ve wrote code snippets in the post above how I did it.
As creating endpoints and general work with express server on nodejs is not Atlassian Connect specific thing, you can find a lot of information about it online.
For example check this:
Authors Show/Edit/Update/Delete Routes - Node.js/Express/MongoDB Course #5 - YouTube.

1 Like

Hi @PiotrStaro,
I was out of the loop for a few days, do you still need my assistance or is everything clear for you now?

Hi @BeataSzturemska,
I am still struggling with this problem. on top of that, I’ve heard that webhooks can’t be trusted because they may not send all the values ​​- is that true?