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

Need to Edit and commit a file using the REST API

TTait April 11, 2022

I am working on a project in python, where we need to either edit an existing file in bitbucket or add a new file, and then create a pull request.  i have been looking at the documentation which uses curl, and not the requests library, which is the preferred python method from my understanding.  

when i try to add a file, i keep getting an unsupported type (415) error.  i have set the content-type to application/json, but i'm unclear how to translate the file into the request.  here is my code:

 

headers = { "Content-type"'application/json'           

            'branch''test/new_branch'

            'message''testing insertion',

            'sourceCommitId'None}

myUrl = projectURL + '/browse/main2.tf'


r = requests.put(myUrlheaders=headersdata=open('main2.tf''r'), verify=Falseauth = HTTPBasicAuth(username,password))

i have not been able to find any example that shows what i'm trying to do.  

is there any documentation on this that anyone might know of?  

 

thanks,

-timothy

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events