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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,552,043
Community Members
 
Community Events
184
Community Groups

What API version does my corp BB server is on?

How can I figure out on what API version my corp Bitbucket server has? we are on Atlassian Bitbucket v7.8.1 now.

http://<host>/bitbucket/rest/api/1.0/projects/<id>/repos

or

http://<host>/bitbucket/rest/api/latest/projects/<id>/repos

gives a list of expected JSON response but when I do

http://<host>/bitbucket/rest/api/2.0/projects/<id>/repos

it throws 'requested source is not available.' So does this mean the API is not beyond v1.0? or am I not pointing to the correct end point?

1 answer

0 votes
Maciej Adamczak
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 27, 2021 • edited

Hi @Pratik , For most of the cases, the 1.0 version is what you want to use. You can check the documentation for all the available API resources here:

https://developer.atlassian.com/server/bitbucket/reference/rest-api/

Once you are on the page with the API references, e.g. https://docs.atlassian.com/bitbucket-server/rest/7.17.0/bitbucket-rest.html
you can change the version in browser URL to match your version, e.g. 7.8.1

I did a quick search on this page, and I think neither of the APIs there are using version 2.0.

Thanks,
Maciej Adamczak
Atlassian Developer

Thanks @Maciej Adamczak

I was looking on how to attach a file to bitbucket PR comment from Jenkins pipeline using curl, I have the PR comment part working already. Further looking into it I read bb API should be beyond v2.0.

Question, is bitbucket API v2.0 only available on cloud?

Maciej Adamczak
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 27, 2021

Bitbucket Cloud and Bitbucket Server/DC are two different products and have different APIs.

I don't know how the Cloud APIs are working but I think for the server/DC you can take a look at the `attachemnts` endpoint.

https://docs.atlassian.com/bitbucket-server/rest/7.17.0/bitbucket-rest.html#idp204

You should be able to send the binary file with the POST request. I'm not sure why, but it's missing in the docs. You can try using the regular Bitbucket commenting UI and browser devtools to try to recreate the request.

Like Pratik likes this
Maciej Adamczak
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 27, 2021 • edited

Example of the request:

Add file as attachment

 

curl -k -u admin:admin \
     -X POST 'http://localhost:7990/projects/{projectKey}/repos/{repositorySlug}/attachments' \
     -H 'Content-Type: multipart/form-data' \
     -F 'files=@foo.txt'

As a response, you should expect:

SAMPLE RESPONSE
{"attachments":
 [
  {
    "id":"3",
    "url":"http://localhost:7990/bitbucket/projects/TEST/repos/attachments/attachments/3",
    "links":{
        "self":{"href":"http://localhost:7990/bitbucket/projects/TEST/repos/attachments/attachments/3"},
        "attachment":{"href":"attachment:1/3"}
    	 }
   }
 ]
}

Add comment to pull-request, referring attachment in comment's message

curl -k -u admin:admin \
     -H 'Content-type: application/json' \
     -X POST 'http://localhost:7990/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments' \
     -d '{"text": "From Local Drive - [foo.txt](attachment:1/3)"}'

 

Like Pratik likes this
Ellen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Jan 27, 2023 • edited Feb 24, 2023

.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events