Getting 401 when POSTing to /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches

Documentation is at https://docs.atlassian.com/bitbucket-server/rest/6.2.0/bitbucket-rest.html#idp176

I use token authentication. I have write access to the repo and admin access to the Project. There are no branch permissions defined for the repo or the Project.

POST returns 401 without any error message in the body.

I have triple checked my code.

Any help is appreciated.

We use Bitbucket v5.8.0

Hi @marten.gustafsson,
Can you please provide some more details about how you’re doing token authentication?
Can you please provide some more details about how you’re doing token authentication? Can you please provide an example of the authorization header?
There are two ways to authenticate with a personal access token:

  • Bearer authentication (curl -H "Authorization: Bearer <token>")
  • Basic authentication using the token as the password (curl -u username:token)

"Authorization: Bearer " in a groovy script. In the same script I am using the same token successfully for a GET.

Using basic authentication (in header) works.

The problem was the token. It was created without WRITE permission.