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,556,415
Community Members
 
Community Events
184
Community Groups

add boilerplate code from an old repository to a new one using an API

Abhishek Kumar
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!
Mar 28, 2023

Hello,

I'm working on a project in JS and I have boilerplate code in one repository that I want to add to a new repository I just created in Bitbucket.

I've heard that it's possible to do this using the Bitbucket API, but I'm not sure how to get started. Specifically, I want to know:

- Which Bitbucket API should I use to add code to a new repository?

- What is the syntax for adding code to a new repository using the API?

- Are there any limitations or restrictions to adding code in this way?

 

Any help or guidance would be appreciated. Thanks in advance!

 

Regards,

Abhishek

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Mar 30, 2023

Hello @Abhishek Kumar ,

Welcome to Atlassian Community!

If you would like to commit a file to a repository using the API, you might want to use the Create a commit by uploading a file endpoint.

Following is an example of a request to that endpoint : 

curl -X POST -u username:app_password https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/src -F /repo/path/to/image.png=@image.png

This would create a new commit in the repository by uploading a local file named image.png and saving it in the repository under the directory /repo/path/to/image.png. 

In this example, we are authenticating the request using the bitbucket username (which you can find in your Personal Settings) and an App Password.

For additional examples of the usage of this endpoint, you're also welcome to check its official documentation in the link below : 

Thank you, @Abhishek Kumar !

Patrik S

Suggest an answer

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

Atlassian Community Events