Post Webhook REST API Edited

Hello,

I am trying to use the "Post Webhooks for Bitbucket" add-on/plugin for my project and was wondering if there is a way to configure webhooks via REST api.

Currently, I am implementing a specific service to detect repo being created and seed the configurations including the post webhook. This endpoint listed in the documentation did not work for me: http://example.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks.

Edit: I realized that the doc I was looking at was for the latest release of the server. I am using v4.9.1, which doesn't seem to have the endpoint. Is there no other way to make this work on this version? Also, is this the correct endpoint to achieve my goal here?

 

Thank you!

 

2 answers

I'm currently using Bitbucket v4.12.1 and these endpoints works for me:

GET: /rest/webhook/1.0/projects/{projectKey}/repos/{repositorySlug}/configurations

to get existing webhook data of a particular repository. The response is similar to this:

[
{
"id": 123,
"title": "Webhook's title",
"url": "https://your.server/webhook",
"committersToIgnore": "",
"branchesToIgnore": "",
"enabled": true
}
]

PUT: /rest/webhook/1.0/projects/{projectKey}/repos/{repositorySlug}/configurations

to create a webhook. The request body should be similar to this:

 {
"title": "Webhook's title",
"url": "https://your.server/webhook",
"committersToIgnore": "",
"branchesToIgnore": "",
"enabled": true
}

 

DELETE: /rest/webhook/1.0/projects/{projectKey}/repos/{repositorySlug}/configurations/{ID}

to remove an existing webhook.

 

I hope helped you!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

....sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables ROLLBAR_ACCESS_TOKEN...

180 views 0 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you