REST API to update multiple files

Is there any way to update multiple files at once with the REST API for the Bitbucket Server? I have been successful updating a file via /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*} (Docs) but this is limited to a single file.

The Bitbucket Cloud has the /2.0/repositories/{username}/{repo_slug}/src (Docs) which allows to create/update/delete multiple files at the same time.

Is there a REST API that can do the same thing but for the Bitbucket Server?

Alternatively, is there a Java API for the Bitbucket server to do a similar action (or low level api to create git commits, blobs, etc)? I don’t mind creating a plugin to extend the existing REST API.

Hi @matus.novak,
Unfortunately Bitbucket server doesn’t have a REST or Java API to update multiple files at once. You could implement a bulk REST API which would call ContentService#editFile() for every file in the bulk update request. ContentService#editFile() can update only one file at a time.

Thanks,
Justin Thomas
Bitbucket Server

Hi @jthomas

Thank you for a quick reply!

I will go with the suggested method.

With regards,
Matus Novak

In the end, I actually went with GitCommandBuilderFactory.

The builder allows running any git command on the repository itself. Using commands “hash-object” and “commit-tree” it is possible to add or modify multiple files at once.

Hopefully it will be useful for anyone trying to solve a similar problem.