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,553,780
Community Members
 
Community Events
184
Community Groups

Return commit hash after creating a commit using API

The Create a commit by uploading a file endpoint doesn't return anything. I need the commit hash that it has created. Is there a workaround for this?

2 answers

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 12, 2023

Hi @Jonathan Li!

With curl, it is possible to add the -v option, as follows:

curl -u BitbucketUsername:AppPassword -v https://api.bitbucket.org/2.0/repositories/workspace-id/repo/src \
-F myFile.txt=@myFile.txt

When the -v option is added, the output will return, among other things, a line that looks like this:

< location: https://api.bitbucket.org/2.0/repositories/workspace-id/repo/commit/361fbb45757afc4056a400730bd6cf6fe3e77c07

The last part is the commit hash of the commit created by the API call.

Kind regards,
Theodora

0 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 06, 2023

If it doesn't return it, maybe you could get the refs from the repo right after you created the commit. Because you know to which branch you created the commit, you need the hash of the head of that branch.

(You could even get the branch itself from the REST API, but as far as I saw it won't return the hash either?!)

Anyway, it should give you an idea.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events