Skip to content

[Bitbucket] Push/edit file using Repository Access token #1107

Open
@kaushalkrishna2000

Description

@kaushalkrishna2000

Bitbucket released repository access token for controlled access to just one repository.
The python wrapper is throwing the error.
"When performing an edit, the author must have an e-mail address."

I need to know is there any way to include email/username in the requests payload ?

For eg.

from variables import *
import requests
import logging

logger=logging.getLogger()
logging.basicConfig(filename = 'myfile1.log', level=logging.DEBUG,
                    format='%(filename)s:%(lineno)s %(levelname)s:%(message)s')


url = f"https://{base_url}/rest/api/latest/projects/~{username}/repos/{repo}/browse/{file}"

contents=None
with open(file,"r") as f:
    contents=f.read()

payload={
    "content": contents,
    "message": "Holla",
    "branch": "master",
    "sourceCommitId": "b244ade3b96",
}
data={
        "author":{
            "name":"example",
            "emailAddress":"ex@example.com"
        }
    }

headers = {
    "Accept": "application/json",
    "Authorization": f"Bearer {auth}"
}

response = requests.request(
   "PUT",
    url=url,
    headers=headers,
    files=payload,
   '''maybe add a json or data payload'''
)


print(response)
print(response.content)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions