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

Adding multiple new files to bitbucket enterprise server using REST API 1.0

uttamag March 3, 2019

I am able to add new file to bitbucket server using below URL

 

http://localhost:7990/rest/api/1.0/projects/BLAC/repos/sddc-test/browse/checkin1.txt

 

form data

branch: master

message: Update README and File content

content: Hello

sourceBranch:<commitid>

 

I want to know if I can add multiple files using the same API and how ?

 

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 6, 2019

Hello Uttam and welcome to the Community!

The API endpoint which your using will only allow a single file to be uploaded/edited per call. This means you’ll need to write a script to accomplish uploading multiple files. I would approach writing the script in the following method:

  1. Have script locate all files within the folder you’re wanting to upload.
  2. Place the path and filename of each file into an array.
  3. The script will then “DO WHILE/UNTIL” read through the array line by line making an API call to the following endpoint: (/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}.
    1. For each call, you will replace the path and filename with the item from the array.
  4. Have the "DO WHILE/UNTIL" complete once all lines of the array have been read.

Each scripting language will approach this differently and your end result will be based more on what you’re wanting to accomplish and what other requirements you may have.

I hope this proves helpful in using the API to upload/edit files into Bitbucket along with giving an idea of how to approach writing such a script.

Regards,
Stephen Sifers

uttamag March 6, 2019

Thanks Stephen, Yes I am using Java to upload multiple files in a loop. So as per your answer this is only way to upload multiple files. We cannot upload multiple files using single REST calls. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events