Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Create tag using REST api for bitbucket server

I was following the API docs https://docs.atlassian.com/bitbucket-server/rest/6.10.0/bitbucket-rest.html?_ga=2.33858657.1166200213.1595259633-444055661.1594387875#idp347. but it seems that is not working for Private Enterprise Bitbucket Servers. 

 

What I found that for Enterprise, the API access is formed in the way

 

{my-private-bibucket-server}//rest/api/latest/projects/{project-id}/repos/{repo-id}/

 

I was able to fetch tags by using 

 

GET {my-private-bitbucket-server}/rest/api/latest/projects/{project-id}/repos/{repo-id}/tags 

 

However, when I try to do a POST 

 

post {my-private-bitbucket-server}/rest/api/latest/projects/{project-id}/repos/{repo-id}/tags 

 

with the body 
{
"name" : "test-tag",
"
startPoint" : {
     "hash" : "<some hash value>"
  }
}

it doesn't work

I am using powershell 

1 answer

1 accepted

0 votes
Answer accepted

Hi there!

I'd love to help out here but am interested in what error you're getting. Fairly regularly when people try to switch from a GET to a POST (at least in Postman), the Content-Type header doesn't get set. If it isn't there, Bitbucket will respond with a 415 Unsupported Media Type error.

image.png

If you're using the Invoke-RestMethod cmdlet in Powershell, adding the ContentType flag should patch up error 415:

-ContentType 'application/json'

 

Now if you're getting a 500 Internal Server Error for your request, I think it's because the structure isn't quite what Bitbucket Server is looking for. Try this body instead:

{
"name" : "test-tag",
"startPoint" : "<some hash value>"
}
The start point parameter is expecting a single value instead of an array. And less nesting means it's more readable too!
Cheers,
Daniel

I did get it working - Ended up being you can not have any spaces in the tag name.

Would be nice to have better error handling, Or have that info in the documentation  

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,914 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you