Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-22568

Cannot create a repo via /2.0/repositories/{workspace}/{repo_slug} with PAT

XMLWordPrintable

      Issue Summary

      Cannot create a repo via /2.0/repositories/{workspace}/{repo_slug} with project access token (PAT)

      Steps to Reproduce

      1. create a PAT from project settings with scope repository:admin
      2. try creating a repository using create repository API endpoint

      Expected Results

      The repository should be created

      Actual Results

      The below error is thrown in the API response:

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

      Workaround

      • API Token: You can use an API Token as a workaround. This approach should work smoothly as long as the user has the necessary permissions to create a repository.
      • Workspace Access Tokens: Another option is to use a Workspace Access Token. This functions similarly to a Project Access Token but offers permissions across the entire workspace, providing more extensive access.

      Example using API Token:

      curl --request POST \
      --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \
      --user '{user_email_address}:{api_token}' \
      --header 'Content-Type: application/json' \
      --data '{
          "is_private": "true",
          "scm": "git",
          "project": {
              "key": "TEST"
              }
          }'
      

              Unassigned Unassigned
              f2cc5e9850cf Suhas Sundararaju
              Votes:
              19 Vote for this issue
              Watchers:
              18 Start watching this issue

                Created:
                Updated: