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

How to update a specific branch repo file using api

rahul kallur
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!
April 4, 2024

I checked this API https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src

whenever i upload the file, it will get created or updated in the main branch only, despite of specifying the branch name

Below is the example:
https://api.bitbucket.org/2.0/repositories/test-node-workspace/node-rest-server/src?branch=dev

But its not working

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 9, 2024

Hello @rahul kallur and welcome to the community.

By default, if not otherwise specified, the commit will be created on the top of the main branch of the repository. If you would like to commit to a different branch, you will need to provide a form-data field with the key branch containing the name of the branch to which you want to commit.

Following is an example of using the API to commit a file to a branch named development:

curl -X POST -u username:app_password https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/src \
  --data-urlencode "/folder/inside/repo.txt=Content of the file" \
  --data-urlencode "message=My commit message " \
  --data-urlencode "branch=development"

Could you try with a request similar to the above and let us know how it goes? 

Should you have any questions, feel free to ask.

Thank you, @rahul kallur !

Patrik S

rahul kallur
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!
April 10, 2024

Thank you, @Patrik S 
It's working

Like Patrik S likes this
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2024

Awesome! Happy to hear it's working :)

If you ever need help in the future, feel free to reach out to Community!

Patrik S

Suggest an answer

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

Atlassian Community Events