Making a commit through Bitbucket Server REST API - 405 Error

I'm trying to use the Bitbucket Server REST API to make a commit, either uploading a new file or modifying an existing one. 

According the the documentation (https://developer.atlassian.com/static/rest/bitbucket-server/5.4.0/bitbucket-rest.html#idm140014937011952) this can be done by making a PUT request to 

rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*} 

encoding as multipart form. However, when I do this I get an HTTP 405 error (Method Not Allowed) and indeed when I make an OPTIONS request to this URL I see that only GET, OPTIONS are allowed.  

What is going wrong and how do I use the REST API to make a commit?

I am using Stash version 4.2.3 so it's possible this is a version issue and I'm also trying to commit to a personal repository with a user-centric URL. I have made various successful requests to the API with this repository though and this is the only one that isn't working.

All help is very much appreciated!

1 answer

I faced the same hurdle and resorted to using JGit. Did you ever find out how to commit using this API?

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

712 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot