Hi,
I am trying to upload an attachment (.txt) to our Jira DC instance using python script below what is weird is if I try to upload txtfile1.txt which has some bunch of random txt around 1MB I always get an error but if I try to upload txtfile2.txt which should be some small txt data which I manually input the script works fine and attachment can be uploaded. Could please help me why is this the case on my end.
import requests
jira_base_url = "https://jira.atlasian.ag"
issue_key = "sample-123"
jira_token = "mysuperDuperSecretKey"
file_path = r"C:\path_to_directory\txtfile1.txt"
upload_url = f"{jira_base_url}/rest/api/2/issue/{issue_key}/attachments"
headers = {
"Authorization": f"Bearer {jira_token}",
"X-Atlassian-Token": "no-check",
"Accept": "application/json",
}
files = { "file": (open(file_path, "rb")) }
try:
response = requests.post (upload_url, headers=headers, files=files)
if response.status_code == 200 or response.status_code == 201:
print("Attachment uploaded successfully!")
print("Response:", response.json())
else:
print(f"Failed to upload attachment. Status Code: {response.status_code}")
print("Response:", response.text)
except Exception as e:
print("An error occurred:", str(e))
Error = Failed to upload attachment. Status Code: 500
Response: {“message”:“org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. /…/jira-data”,“status-code”:500,“stack-trace”:“Please contact your admin passing attached Log’'s referral number: e74502dd-1907-40f0-8d50-423150b22d2e”}
Jira DC 9.17.4 attachment limit = 80M