Not able to register webhook for my app

I’m calling the following API to register a webhook:

https://api.atlassian.com/ex/jira/{cloudId}/rest/api/2/webhook

with the body :

{

"name": "my first webhook via rest",

"url": "https://callbackurl.com",

"events": [

"jira:issue_deleted",

"jira:issue_updated"

],

"excludeBody" : false

}

but i’m getting the following error:

{
    "message": "Cannot invoke \"java.util.List.stream()\" because the return value of \"com.atlassian.jira.rest.v2.webhook.DynamicWebhookRegistrationRequestBean.getWebhooks()\" is null",
    "status-code": 500,
    "stack-trace": ""
}

Hi @Surya,
thanks for your report!
Indeed the response we returned from the API isn’t descriptive and should be improved. Sorry for that.

When it comes to you request, it looks you mixed two APIs in your request.

The url you mention: POST /rest/api/2/webhook is allowed only for Connect and 3LO apps and it expects the payload like:

{
   "url": "https://your-app-base-url.com/webhook-received",
   "webhooks": [
      {
         "jqlFilter": "project = PRJ AND status = Done",
         "events": ["jira:issue_created", "jira:issue_updated"]
      },
      {
         "jqlFilter": "status = Done",
         "events": ["jira:issue_updated"]
      },
      {
         "jqlFilter": "myClause = something",
         "events": ["jira:issue_deleted"]
      }
   ]
}

See more: docs

While the payload you pasted, it used in the API used to register “admin webhooks” - the same the admin can see in the Jira Webhooks UI and the proper url to send this request it POST /rest/webhooks/1.0/webhook.
See more: docs

I hope it helps.
Beata

1 Like

thanks for the quick help !