I'm running JIRA 6.0.4 and I need to temporarily disable and re-enable a webhook from an external script. Basically, I just need a curl command that lets me edit a JIRA Webhook. The closest I've come is
curl -u alex:alex http://jira-base-url/rest/webhooks/1.0/webhook/2
which gives me the details of the second webhook (the one I care about). Unfortunately, I haven't been able to figure out what the correct incantation is to disable the webhook. I've been trying stuff like
curl -D- -u alex:alex -X POST --data '{"enabled": false}' -H "Content-Type: appliation/json" http://jira-base-url/rest/webhooks/1.0/webhook/2
but I haven't hit on the right thing. Any ideas? I've seen people talking about being able to edit webhooks through the REST API as of a couple years ago, but they cite documentation that's been taken down.
EDIT: I answered my own question, but Atlassian Answers won't let me post more than three things in 24 hours since I have a fairly young account. Here's what I would have posted as an answer:
Hey future person looking for a solution to the same thing I was,
It looks like the REST API only supports creating, deleting, and viewing webhooks. I did a bunch of research and it looks like it might have existed a few years ago, but it's not documented any more and I didn't find any actual URLs or POST blobs showing how to do it.
My problem was essentially two webhooks (JIRA and something else) that would feedback into each other, and I needed to make sure that the two webhooks would never be running at the same time (one could trigger the other). I solved it by making a couple lockfiles that are hooked up to the script the webhook phones home to. Using a lockfile also gives me much higher resolution control, since I only "disable" the webhook for specific issues instead of momentarily disabling the webhook for everything.
Community moderators have prevented the ability to post new answers.
You can try this to enable/disable Webhook via REST API:
{code}
curl --user username:password -X PUT --data '{"enabled":false}' -H "Content-Type: application/json" http://localhost:8080/rest/webhooks/1.0/webhook/<webhook ID>
ex. curl --user testuser:welcome1 -X PUT --data '{"enabled":true}' -H "Content-Type: application/json" http://localhost:8080/rest/webhooks/1.0/webhook/7
{code}
This is a pipe I use with BitBucket 5.x
curl -n -s -q -X GET -H 'Content-Type: application/json' https://bitbucket/rest/api/1.0/projects/$PROJECTNAME/repos/$reponame/webhooks/$webhookid | jq '.active=false' | curl -n -s -q -X PUT -H 'Content-Type: application/json' https://bitbucket/rest/api/1.0/projects/$PROJECTNAME/repos/$reponame/webhooks/$webhookid -d @-
Note: you need to create a ~/.netrc first for curl -n to work. Also you need jq installed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex!
I think there is no way to enable/disable webhooks but you can delete/create them. Please see here: https://developer.atlassian.com/jiradev/jira-architecture/webhooks
// To create a webhook, you simply POST a webhook in JSON format to: // <JIRA_URL>/rest/webhooks/1.0/webhook // An example of a webhook JSON to POST is below: { "name": "my first webhook via rest", "url": "http://www.example.com/webhooks", "events": [ "jiraissue_created", "issue_updated" ], "jqlFilter": "Project = JRA AND resolution = Fixed", "excludeIssueDetails" : false, } // Unregistering / deleting a webbook via REST curl --user username:password -X DELETE -H "Content-Type: application/json" http://myveryownjira.atlassian.com/rest/webhooks/1.0/webhook/70
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volodymyr, Thanks, I ran into that earlier. It'll probably be my fallback, but I'd much rather work with an existing web hook. It looks like it used to be possible to edit webhooks via the REST API as of 2013, I found this earlier: https://answers.atlassian.com/questions/190155/what-is-the-urls-for-creating-webhook According to that post, someone was able to "create, _edit_ and delete webhooks using webhooks rest" (emphasis mine). They reference using latest instead of 1.0 for the API and link to https://developer.atlassian.com/display/JIRADEV/JIRA+Webhooks+Overview which unfortunately no longer exists.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not believe it was possible to _edit_ since it's not documented. I guess it's a typo. "latest" in JIRA REST falls back to the latest available API and it's 1.0 for webhooks. Why do not you ask author of the post?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.