Question

I can see that it is possible to add a git hook to Bitbucket in the interface like so:

enter image description here

Is it possible to add a POST hook like this using Bitbucket's API instead of using the web interface? Is it possible to remove an existing hook using the API?

Was it helpful?

Solution

services resource might help you.

Create a POST service example:

curl -u tutorials:8798987 -X POST https://api.bitbucket.org/1.0/repositories/tutorials/testrepo/services/ -d "type=POST&URL=https%3A%2F%2Fbitbucket.org/post"

This will create a new POST hook with https://bitbucket.org/post as URL:

{
    "id": 5,
    "service": {
        "fields": [
            {
                "name": "URL",
                "value": "https://bitbucket.org/post"
            }
        ],
        "type": "POST"
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top