Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 500 status code while updating a file using bitbucket Rest API (From backend)

aryan_pidiha
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 25, 2025 edited

URL: 

'https://${BASE_URL}/rest/api/latest/projects/~USER_COMPANY.IN/repos/figma-props/browse/test.md'

When i'm trying to update a file in a repo using this API i'm getting an error (Status code 500):
{ "errors": [ { "context": null, "message": "An error occurred while processing the request. Check the server logs for more information.", "exceptionName": null } ] }


async function commitChanges(branchName, latestCommitId) {
console.log('update file called');
const url = 'https://${BASE_URL}/rest/api/latest/projects/~USER_COMPANY.IN/repos/figma-props/browse/test.md';
const formdata = new FormData();
formdata.append('content', 'value - t1');
formdata.append('sourceBranch', branchName);
formdata.append('sourceCommitId', latestCommitId);
formdata.append('branch', branchName);
formdata.append('message', 'test.md edited online with Bitbucket');
console.log('form-->>>', formdata);
const requestOptions = {
method: 'PUT',
headers: {
Authorization: `Bearer ${token}`,
accept: 'application/json',
'content-type': 'multipart/form-data',
},
body: formdata,
};

try {
const result = await fetch(url, requestOptions);
console.log('API res-->>', result);
}
catch (error) {
console.log('error-->>>', error);
}
}


Additional Info:
I'm not calling the API from the frontend, i'm calling a backend API which is calling the update file API('https://${BASE_URL}/rest/api/latest/projects/~USER_COMPANY.IN/repos/figma-props/browse/test.md')

I've tried hitting the API from postman and there's a Cookie which is getting passed 
if i remove that Cookie from the header i get the 500 ERROR
My hunch is the ERROR is because of the Cookie, but that Cookie keeps changing 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events