Not able to add new file using bitbucket server api.
Also please help me in repairing my code.
auth is repository access token
from variables import base_url,repo,file,username,auth
import requests
import json
url = f"http://{base_url}/rest/api/latest/projects/~{username}/repos/{repo}/browse/{file}"
contents=None
with open(file,"r") as f:
contents=f.read()
payload={
"branch": "master",
"content": contents,
"message": "Holla",
"sourceCommitId": None
}
headers = {
"Accept": "application/json",
"Authorization": f"Bearer {auth}",
"Content-Type": "multipart/form-data"
}
response = requests.request(
"PUT",
url,
headers=headers,
json=payload
)
print(response)
Can someone please help ???????????
Hi @Kaushal Krishna , I'm using the same api to add a file to repo and getting the following error response:
409
{
"errors": [
{
"context": null,
"message": "Support for editing files has been disabled.",
"exceptionName": "com.atlassian.stash.internal.rest.content.ContentResource.FileEditorDisabledException"
}
]
}
Did u face the same issue? If yes .. can u pls help me understand and fix it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not clear with what is accepted. Pls do provide the details. instead of the python code can we use a cul command to add file in the repo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kaushal Krishna ,
what is the answer ? can you please share it? what is the final api endpoint which you have used?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.