I'm attempting to use the API to script repo creation, but I'm getting a 401 authorization error. I'm using basic HTTP authentication, with my username and a personal access token. I'm in the "administrators" group, which has Admin access to the project, and I specified Admin access for my personal access token. I'm using this URL:
https://<our server address>/rest/api/1.0/projects/EP/repos
I'm making a POST request with the Content-Type "application/json" and the body (though I tried with all 3 documented parameters and it didn't make a difference):
{
"name": "TestRepo"
}
I'm in BitBucket Server 5.15.0, and the GET request to the same URL using my Personal Access Token returns the list of projects. Also, using my regular password works as expected. This is the response I'm getting for the POST request authenticating with my token:
HTTP/1.1 401
Server: nginx/1.14.0
Date: Wed, 17 Apr 2019 22:24:00 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
X-AREQUESTID: @1Q2IL9Zx1344x744323x0
X-ASESSIONID: 13r0hpv
X-ASEN: SEN-11784298
Set-Cookie: crowd.token_key=<redacted>; Domain=<redacted>; Path=/; HttpOnly
X-AUSERID: 53
X-AUSERNAME: dfrankel
Cache-Control: no-cache, no-transform
Vary: X-AUSERNAME,Accept-Encoding
WWW-Authenticate: OAuth realm="https%3A%2F%2F<our server address>"
X-Content-Type-Options: nosniff{"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}
Hello Dov,
While you have reported you’re an administrator (and there is no doubt there), this error is related to your user/token not having the proper permissions. You must ensure your permissions for the user/token are set to have PROJECT_ADMIN permissions for the parent project they’re accessing. More about the permission levels for the tokens may be found at Personal access tokens. Once you have set or ensured the user/token is assigned the proper permissions, please attempt your POST call again to the create repo endpoint.
Do let us know if you have the same issue again along with if you’re able to create the repo after the adjustment.
Regards,
Stephen Sifers
Whoops. Repo permissions were Admin, but Project was set to Read. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very happy you're able to find the issue and resolve it quickly!
Do reach out again if you run into any more problems.
Regards,
Stephen Sifers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.