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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.