Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,300,791
Community Members
 
Community Events
165
Community Groups

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  

Hello,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 to create tag.

I was able to fetch tags by using GET in postman

image.png

 

But when I try to do POST, I get 500 Internal Server Error

image.png

 

I was confused

Suggest an answer

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

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,263 views 2 9
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