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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,460,567
Community Members
 
Community Events
176
Community Groups

How to use bitbucket repository access token to edit a file with bitbucket server rest api .

I need to know if we could use the repository access token to perform edit/push a file with bitbucket server rest api.

Because it is showing the "When performing an edit, the author must have an e-mail address" error .

If someone can show me how to add the email address (without adding personal access token) to the payload then I would be grateful .

Using personal access token will be sort of risky to use .

auth=repository access token

The code :

import json
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": "016cf822394",
}
data={
"author":{
"name":username,
"emailAddress":user_email
}
}

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

response = requests.request(
"PUT",
url=url,
headers=headers,
files=payload,

)


print(response)
print(response.content)

0 comments

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events