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

Rest api endpoint to create a folder in forked repository.

Sravya Nalla September 4, 2023

The requirement is -

I should be able to create a folder inside forked repo and in the newly created folder,i should next create two files.

The idea is to automate this process without having it to be done in local system.

 

1 answer

2 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 5, 2023

Hey @Sravya Nalla and welcome to the Community!

You can leverage the Create a commit by uploading a file endpoint to commit the files you want using the rest API.

Following is an example API request to that endpoint using curl : 

curl -X POST -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPOSITORY/src -F /my_folder/myfile.txt=@myfile.txt

This will create a new commit on top of the main branch, uploading the local file myfile.txt to the directory my_folder inside the repository. If the destination folder does not exist in the repository, it will get automatically created.

In this example, we are using basic authentication to authenticate the request, where :

For additional details on that particular endpoint, you can refer to the official API reference below : 

Hope that helps! You can try following the example above and let us know how it goes. 

Thank you, @Sravya Nalla !

Patrik S

Sravya Nalla September 6, 2023

Hi @Patrik S , thanks for the response!!

Here i don't want to upload any files from local system instead I want to create folder and files(ymls) inside that folder using endpoints.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events