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

Create a commit by uploading a file API with query params won't work

Nimrod Golan November 13, 2023

Hi,

I'm trying to use the following API in order to update an existing feature branch's file.

I'm using Postman with the following request URL:  https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src?branch=<my-branch> with content-type as "application/x-www-form-urlencoded" as a header and with body as "x-www-form-urlencoded" with the following key-value for the desired file which I want to modify:
key: "/README.md"

value: "new-value"

when initiating the request I'm getting back 201 created status but the file that was modified is the readme file located on my "main" branch and not on my feature branch.

what am I missing here?

 

 

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 14, 2023

Hello @Nimrod Golan and thank you for reaching out to Community! 

The Create a commit by uploading a file endpoint expects the branch name to come as one of the key/value pair when using application/x-www-form-urlencoded. You can try to specify the key as branch and the value as the branch name : 

  • key: "branch"
  • value: "branch_a"

This should make the commit to be created on the top of the branch provided. 

Could you try that suggestion and let us know how it goes? 

Thank you, @Nimrod Golan !

Patrik S

Nimrod Golan November 15, 2023

That worked, thanks! maybe it's better refine it on the endpoint documentation.

Like Patrik S likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events