List of remote repositories

Steven Burck October 22, 2023

I am writing a BASH script which needs to get remote information from Atlassian GIT.  The information is a list of repositories in a given project.  What I have to do to get this information currently is to make an application with a web browser which goes to that directory, wait for the page to load, then parse the results and strip out the unneeded information.  Is there an API in which I could do this?

1 answer

1 accepted

0 votes
Answer accepted
Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 23, 2023

Hi @Steven Burck ,

Welcome to the Atlassian Community, sounds like you need the Bitbucket REST API, check out this specific endpoint: https://developer.atlassian.com/server/bitbucket/rest/v814/api-group-project/#api-api-latest-projects-projectkey-repos-repositoryslug-get

I believe that's what you're looking for.

Cheers,
Peter

Steven Burck October 23, 2023

Thanks very much Peter.  I'm trying it now, but getting back

{"errors":[{"context":null, "Message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket/AuthorisationException"}]}

which seems pretty self-explanatory, but AFAIK I have rights there (trying to get the admin to check this, may take a while).  I know that I can see the project and modify it in the browser.  I see in the documentation that I only need PROJECT_READ.

Steven Burck October 23, 2023

As far as the admin is concerned, I have read and write access to the project.

Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 23, 2023

Hey @Steven Burck ,

Can you try calling any other API endpoint and see if those work? If not it might be that you're not authenticating properly when calling the API endpoint.

Also to get the actual repository information you'll need REPO_READ permissions too.

Cheers,
Peter

Steven Burck October 23, 2023

I'm doing a lot of experimentation, the problem is that it's on a secure server, so I'm retyping everything here, so (a) it goes slowly, and (b) I make mistakes, and so it goes even more slowly.

One of the problems is I'm unsure of what the {baseURL} should be.  I tried both

http://servername:7990/  (which results in the not permitted response)

and 

http://servername:7990/scm  (which results in a 404 response)

Here, the full command is

curl --request GET --url 'http://sername:7990/scm/rest/api/latest/projects/IPP2/repos' --header 'Accept: application/json' (or without the /scm)

with the 404 response appears:

{"message":"null for uri: http://servername:7990/rest/api/1.0/scm/rest/api/latest/projects/IPP2/repos","status-code":404} 

Note the duplication of 'rest/api' in the url of the response, I find that curious.

Without the scm the response was as in the previous answer (not permitted)

For a different endpoint, (http://servername:7990'/scm/rest/api/latest/groups) the results were exactly the same - 

with scm, 404 with the url having the repeated rest/api in it, and without "not permitted"

Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2023

Interesting, but also frustrating.

Does your admin see anything in the log files that might help you out?

Steven Burck October 24, 2023

Sorry it took so long, my administrator was out and so I used Wireshark to see the differences between using the browser and curl.  The different was username, which, when I added it to my curl request, went fine.  I have to see how to go about setting up a netrc file with this data, as I really can't put it in the command.  Thanks for the help.

Like Peter Van de Voorde likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events