Forums

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

Cloud API - Create Repository

Ryan Mangum October 13, 2023

I'm having some difficulty creating a repo under a workspace using the cloud API through a repo setup script. This is the curl command:


curl --request POST \

--url "https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}" \

--header "Authorization: Bearer ${BITBUCKET_REPO_SETUP}" \

--header "Accept: application/json" \

--header "Content-Type: application/json" \

--data "{

\"type\": \"repository\",

\"name\": \"${repo_slug}\",

\"project\": {

\"key\": \"${PROJECT_KEY}\"

}

}"

When I execute this command I get the following error:


{
"type": "error",
"error": {
"message": "You do not have access to view this workspace."
}
}

This is seemingly a permission issue, so the first thing I did was check the project access token's permissions. I verified it has the correct permissions:

  • repository
  • repository:admin
  • repository:delete
  • repository:write

When I execute a GET request with the same token to the same workspace I get a successful response:

curl --request GET \ 
--url "https://api.bitbucket.org/2.0/workspaces/${workspace}" \
--header "Authorization: Bearer ${BITBUCKET_REPO_SETUP}" \
--header "Accept: application/json"

What am I missing?

 

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 15, 2023

G'day, @Ryan Mangum 

Welcome to the community!

Are you an administrator of the workspace with the ability to create a repository through the user interface? If so, which type of token did you use to create the repository? There are three types of tokens available: the Workspace token, the Repository token, and the Project token, which is referred to as the Bitbucket Access Token.

If you do not have administrative privileges in the workspace, it is expected that you won't be able to create a repository due to insufficient permissions hence the error

You do not have access to view this workspace  

You need to request your administrator to provide you with access to create a repository to allow you to create a repository.

I hope this helps.

Regards,
Syahrul 

Ryan Mangum October 16, 2023

I am an administrator for the project, and the request above is being sent with a project level access token. Just so I understand, I cannot create a repo within a project that I have an admin token for, and I will need a workspace admin token to do this?

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 16, 2023

Hi @Ryan Mangum 

It looks like there's a bug with the Project access token with the create repository endpoint that is currently tracked at:

https://jira.atlassian.com/browse/BCLOUD-22568

Please Vote and Watch the bug report so that you'll receive an update whenever it's fixed.

As a workaround, please use App Password instead temporarily.

I hope this helps.

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events