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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Commit file using REST API


I'm building a web based editor (in React) which needs to commit changes to our BitBucket repo. GET requests seem to working perfectly however the code below is returning a 415 error which I think relates to incorrect content/meta type..?

There's no mention of how to specify a meta type in the docs,

Is meta type the real problem here? or have I done something else wrong?

Can anyone help?


const url = new URL(`${workspace}/${repo}/src`);

const params = {
    access_token: query.access_token,
    message: encodeURIComponent("commit"),
    branch: branchName,
    [encodeURIComponent(path + '/start.json')]: "helloWorld"

Object.entries(params).forEach(([key, value]) => {
    url.searchParams.append(key, value)

fetch(url, { method: 'POST' }).then(handleResponse);


1 answer

Here's the fix for anyone searching...


const url = new URL(`${workspace}${repo}src`);
url.searchParams.append('access_token', token);

const data = new URLSearchParams();
data.append('message', commitMsg);
data.append('branch', branchName);
data.append(path, fileContent);

const options = {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
body : data

fetch(url, options).then(

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,755 views 10 16
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you