Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get particular repository for a user using API

Sakshi Barnwal September 12, 2018

Hi Team,

We have a requirement to get repo code using the Bitbucket API. 

I am able to list all the api for a user, using basic auth, but while using the

"https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D"

, it gives a 404 error where I am passing the uuid of repo as the repo slug.

 

Thanks,

Sakshi

4 answers

0 votes
Sakshi Barnwal September 13, 2018

Tyler,

I have tried with the curl braces, but it gave a 404 exception. The repository is a private repository for which I have member access.

For getting the list of repositories, I have used

curl -X GET  --user <username>:<password>https://api.bitbucket.org/2.0/repositories?role=member

and using the uuid for a repo,

curl -X GET  --user <username>:<password> https://api.bitbucket.org/2.0/repositories/<username>/{<uuid_repo>}.

 

Do, let me know if I am missing a step.

Thanks,

Sakshi

Tyler T
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2018

Do you have 2-factor-auth / 2-step-verification disabled? If you use 2fa, you should authenticate using OAuth2 instead of basic auth.

More here: https://developer.atlassian.com/bitbucket/api/2/reference/meta/authentication

Sakshi Barnwal September 17, 2018

We are using basic authentication for bitbucket in the org, hence that shouldn't be the cause for 404 error.

Also, I am able to get the repo list using 

```curl -X GET  --user <username>:<password>https://api.bitbucket.org/2.0/repositories?role=member ```.

Not sure how to proceed further for this. 

Tyler T
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 17, 2018

What is the error response in the 404? It should have a JSON payload with more information about the issue.

Sakshi Barnwal September 17, 2018

{
"type": "error",
"error": {
"message": "Repository <username>/{repo slug} not found"
}
}

 

Please note that I am a member of this repo , not owner.

Tyler T
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 19, 2018

My repo slug you mean repo UUID right? Or does the API call not work for <username>/<slug> either? That response usually means something about the owner name or slug was typed incorrectly, thus it cannot be found. If it was an authentication issue the response code would likely be a 403.

0 votes
Tyler T
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2018

From the API docs:

This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.

Are you using the curly-braces around the UUID?

Here's an example with a public repository:

https://api.bitbucket.org/2.0/repositories/mirror/%7Be14d6747-e69d-4ee3-a64a-a2ec8d3d5034%7D

0 votes
Sakshi Barnwal September 12, 2018

Hi Gonchik,

 

I am able to get all the repository after passing the parameter of role and that's how I have received the uuid corresponding to a repository.

Although, when I am passing the same in the api as mentioned above, it is giving a 404 error.

 

Thanks,

Sakshi Barnwal

0 votes
Gonchik Tsymzhitov
Community Champion
September 12, 2018

Hi! 

 

Let's get all repositoty, 

without repo_slug parameter? 

 

 

Cheers,

Gonchik Tsymzhitov

Sakshi Barnwal September 17, 2018

 

@Gonchik Tsymzhitov

We are using basic authentication for bitbucket in the org, hence that shouldn't be the cause for 404 error.

Also, I am able to get the repo list using 

```curl -X GET  --user <username>:<password>https://api.bitbucket.org/2.0/repositories?role=member ```.

Not sure how to proceed further for this. 

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events