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(myUrl, headers=headers, data=open('main2.tf', 'r'), verify=False, auth = 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