Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Python script 500 internal server error when trying to upload attachment to Jira

Divya Srinivasan January 2, 2019 edited

Hi Team,

 I am trying to upload small size txt file into a Jira Server Issue and below is the python script I am trying to execute.

# ===============

# upload.attachment.py
# ===============
import requests
import json


# [JIRA-BASE-URL], i.e.: http://localhost:8080
# [ISSUE-ID], i.e.: ATT-1
url = '[mycompcorpjiraurl]/jira/rest/api/latest/issue/[issueID]'
headers = {"X-Atlassian-Token": "nocheck"}
# please uncomment to attach external file
files = {'file': open('greetings.txt', 'rb')}


# upload file to issue

r = requests.post(url, auth=('mycompanycorpjiraloginuser', 'mycompanycorpjiraloginpwd'), files=files, headers=headers)
print(r.status_code)
print(r.text)

 

Response:

500
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an unknown error</p>
</body></html>

 

 

I had tried java script for which same response is returned. I  do not have admin rights to view the logs. Please help.

 

1 answer

1 accepted

2 votes
Answer accepted
Marc Minten (EVS)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2019

I think you already forgot the "/attachments" part in your URL ?

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 7, 2025

For other users that might encounter this error when using REST, check out the reference guide for this endpoint in

Suggest an answer

Log in or Sign up to answer