Forums

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

Is any api support for creating and modifying file available in Bitbucket cloud?

ksaravan July 28, 2019

Bitbucket cloud v2.0 api's only support reading file contents, but it does not appear to support creating a new file or modifying existing file content. Is that already available in some other form or planned for the future?.

1 answer

1 accepted

0 votes
Answer accepted
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 28, 2019

Hello @ksaravan,

POST method on this endpoint allows to create, update and delete files: /2.0/repositories/{username}/{repo_slug}/src

Hope this helps.

Cheers,
Daniil

ksaravan July 28, 2019

Thank you so much. I had a look at the documentation link, but i have another question on updating a file by 2 or more people at the same time on the same branch. Does Bitbucket cloud REST api detect and error out appropriately?. 

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 28, 2019

No worries, happy to help.

I have another question on updating a file by 2 or more people at the same time on the same branch. Does Bitbucket cloud REST api detect and error out appropriately?

Yes, this is possible by specifying parents and branch query parameters accordingly. Some cases from the same endpoint documentation page:

  • When a branch name is provided that already exists in the repo, then the commit will be created on top of that branch. In this case, if a parent SHA1 was also provided, then it is asserted that the parent is the branch's tip/HEAD at the time the request is made. When this is not the case, a 409 is returned.
  • When a branch name is not specified, but a parent SHA1 is provided, then Bitbucket asserts that it represents the main branch's current HEAD/tip, or a 409 is returned.
  • ...

There're more cases described there, this is just to give some context.

Let me know if you have any questions.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events