How do I use the DELETE endpoint of the REST API for branches?
https://developer.atlassian.com/static/rest/bitbucket-server/5.5.0/bitbucket-branch-rest.html
Looking at this, I'm supposed to send a request object with the DELETE, but DELETE doesn't support passing an object?
The endpoint should simply be a request to
I don't know how you'll handle the /refs/head/- and forward slashes people use in their requests. But it seems wrong to imply that people should pass an object with their DELETE request.
Or do it like a POST request, to a
With the object, with the name and dryRyn - that would work right out of the box. And the branch-target is inferred by the branch-utils in the beginning of the API.
delete with a return code 204 worked:
https://stash.****.com/stash/rest/branch-utils/1.0/projects/{proj}/repos/{repo}/branches
the body must look like
{
"name": "refs/heads/{Name of the Branch}",
"dryRun": false
}
Use Basic Auth in PostMan and provide your userId and Password
-H 'cache-control: no-cache' -H 'content-type: application/json' -H 'x-atlassian-token: nocheck'
I only get a 405 error when I try this API.
Happens both when I try to create a branch with a post or when I try to delete a branch.
Do you need to do anything special to use this API. Or was this API broken in some bitbucket server versions ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same issue for me, this api does not work on bitbucket server 6.8.0, I get 405 error. Trying to implement a similar functionality to "delete source branch after merging" tickbox when pull requests are merged. Is there any alternative to achieve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how do we do this in postman? I have tried using the example with the json in the 'body' tab of postman and i am getting error 405 : Method Not Allowed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using Bitbucket Server or Bitbucket Cloud? This API is just for BB Server; there is no corresponding endpoint for BB Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is what I have tried and its not working..
curl -X DELETE https://<url>/rest/api/1.0/projects/<abc>/repos/<xyz>/branches
-H 'authorization: Bearer xxxxxx' -H 'cache-control: no-cache'
-H 'content-type: application/json'
-H 'x-atlassian-token: nocheck'
-d '{"name": "refs/heads/feature/name","dryRun": false}'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cante,
You are using the wrong endpoint. As per documentation this should be /rest/branch-utils/1.0/projects/{projectKey}/repos/{repositorySlug}/branches instead of rest/api/1.0/projects/<abc>/repos/<xyz>/branches like you are using now.
BR,
Maarten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nicolaj,
The delete rest end point requires the ref to be specified as part of the input request, not in the URL itself.
If you expand the "Example request representations", you'll get an example json file:
{
"name": "refs/heads/my-branch",
"dryRun": false
}
Add this to your request to provide the input file:
-H
"Content-Type: application/json"
--data
@input
.json
Cheers,
Caterina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.