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?
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As far as the admin is concerned, I have read and write access to the project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Interesting, but also frustrating.
Does your admin see anything in the log files that might help you out?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.