Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

GET with REST API for all branches on BB server 4.13.0

puddleglum2 September 20, 2018

Hi,

is there a way to get a list of all branches for a BB Server repo via a GET similar to the POST and DELETE methods described in https://docs.atlassian.com/bitbucket-server/rest/4.13.0/bitbucket-branch-rest.html?utm_source=%2Fstatic%2Frest%2Fbitbucket-server%2Flatest%2Fbitbucket-branch-rest.html&utm_medium=301#idm45495357768480

I tried sth. like

def response = stash.get(path: "api/1.0/projects/$projectKey/repos/$slug/branches/", contentType: 'application/json', headers: ["Authorization": authenticatonHeader])

and it didn't work... GET always empty Response.

Any help is greatly appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Prasanth
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2018

Hi

Below rest endpoint should give the list of branches in a repository. 

I could see that you are using that in a script. Have you tried with a REST client such as Postman or using cURL ? 

Also, you may check the authentication and the user with which you are trying has the read access.

Best regards,
Prasanth Thaikkalloor

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2018

@Prasanth,

User @puddleglum2 has attempted to respond to you via a duplicate thread with the following:

thanks for the quick answer... but unfortunately it doesn't solve the issue. The link you gave here does not contain a GET method in REST API for ...$slugs... (repos) alone... The only GET available is a GET of the Branch Default Settings like api/1.0/projects/$projectKey/repos/$slug/branches/Default which I use already. We really need this list of all remote branches. In my link above there is e.g. a DELETE method for branches implemented but no GET... can't understand why... (see DELETE("/rest/branch-utils/1.0/projects/{projectKey}/repos/{repositorySlug}/branches" ....)
The access rights do work as we use much of the REST API here.... any further help is still highly appreciated!

Note that I'll be removing the duplicate post, but please feel free to reply directly on this case if you have any further information to provide!

Regards,

Shannon

Prasanth
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 1, 2018

The link which I gave definitely have a GET method. Please see below

Screen Shot 2018-09-28 at 1.30.57 PM.png

/rest/branch-utils/....../branches doesn't have a GET. I tried the above and it worked for me.

puddleglum2 October 25, 2018

Sorry, I had a repeated typo... for sure it now works! Thanks for your help and have a great time! 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events