BitBucket Server API Issue 405 Error

Hello, I’m trying to call the following API and I’m getting a 405 error.

PUT /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/browse/{path}

Here my code sample

var axios = require('axios');
var data = JSON.stringify({
  "branch": "main",
  "content": "C:\ReadMe.txt",
  "message": "Upload From API",
  "sourceBranch": "main"
});

var config = {
  method: 'put',
  url: 'http://bitbucket.**********.com:7990/rest/api/latest/projects/IN/repos/postman-test-rest-api/browse/ReadMe.txt',
  headers: { 
    'Authorization': 'Basic *****************************************', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

1 Like

The Bitbucket Rest API shows a form-based example. I’m not sure ‘application/json’ is a valid request payload format. Have you tried a form-based approach?
Cheers, Ulrich

Hi

I’ve tried with both form-data and x-www-form-urlencoded, and even trying with postman I get the same error

Any luck, is it a server thing or actually issue with bitbucket?