App webhook fails to create

Hi there,

We create an app for Jira.

We use a Jira Cloud instance to test it.

Recently we’ve stopped being able to install it on the above account successfully. As part of our app installation process, we add a webhook to the installing account.

We first check to see if our webhook is already installed. If so we delete it.

Unfortunately this has stopped working. When we check to see if the webhook is already installed the API doesn’t return any webhooks.

When we go to add the webhook to the account we get an error saying we can’t because there is already a webhook created.

Here’s what we are seeing…

# Here's the api url
>>> client._jira.url
'https://api.atlassian.com/ex/jira/<some_id>/'
# No webhooks exist
>>> client._jira.get("rest/api/2/webhook")
{'maxResults': 100, 'startAt': 0, 'total': 0, 'isLast': True, 'values': []}
# Great no webhook so lets make one!
>>> data
{'webhooks': [{'jqlFilter': 'project != "non-existing-project"', 'fieldIdsFilter': ['status', 'summary', 'issuetype', 'project'], 'events': ['jira:issue_updated']}], 'url': '<some_new_webhook_id>'}
>>> res = client._jira.post("rest/api/2/webhook", data=data)
# Error, a webhook already exists for our app!? That doesn't seem right!
>>> res
{'webhookRegistrationResult': [{'errors': ['Only a single URL per app is allowed to be registered via REST API. Currently used URL: <some_old_webhook_id>']}]}

I wonder if maybe this has something to do with this account being recently downgraded (automatically?) to a free account?

Any guidance greatly appreciated!

Just a wild guess, does your app has the required access rights?

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-webhooks/#api-group-webhooks

GET /rest/api/3/webhook

Returns a paginated list of the webhooks registered by the calling app.

Permissions required: Only Connect and OAuth 2.0 apps can use this operation.

Connect app scope required: READ

OAuth 2.0 scopes required:
ClassicRECOMMENDED:read:jira-work, manage:jira-webhook
Granular:read:webhook:jira, read:jql:jira

Yes, I don’t think permissions are the issue. All of this was been working for quite some time. I’m thinking the issue is related to this:

https://jira.atlassian.com/browse/JRACLOUD-78956

It sounds like GET /rest/api/3/webhook is mistakenly returning the webhooks for the user of the current token vs. the all webhooks for the current app which means if you change users you run into this issue.