# Adding attachments to JIRA issues

**URL:** <https://forum.inductiveautomation.com/t/adding-attachments-to-jira-issues/79743>\
**Category:** Ignition\
**Created:** [September 27, 2023, 5:52pm UTC](https://forum.inductiveautomation.com/t/adding-attachments-to-jira-issues/79743 "2023-09-27T17:52:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_ANIL\_KUMAR](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@S\_ANIL\_KUMAR](https://forum.inductiveautomation.com/u/S_ANIL_KUMAR)\
**Post date:** [September 27, 2023, 5:52pm UTC](https://forum.inductiveautomation.com/t/adding-attachments-to-jira-issues/79743/1 "2023-09-27T17:52:25Z")

</div>

Hello, I referred to a script from the forum to send data via http post. So I used the same to add attachments to the jira issues using jira's rest api. I am able add images that are below 50kb where as above 50kb i see the image broken in jira's issue. Could anyone help what's going wrong with the code.

from base64 import b64encode  
import os  
import urllib2

jira\_url = "[https://domain-name/rest/api/2/issue/{issueID}/attachments](https://domain-name/rest/api/2/issue/%7BissueID%7D/attachments)"  
username = "[email.com](http://email.com)"  
api\_token = "api\_token"  
auth =b64encode(username +":"+api\_token)

file\_path = system.file.openFile()  
with open(file\_path, 'rb') as file\_stream:  
file\_data = file\_stream.read()

# Prepare the request

request = urllib2.Request(jira\_url)  
boundary = "----" + hex(hash(file\_data))[2:]  
request.add\_header("Content-Type", "multipart/form-data; boundary={}".format(boundary))

# Encode credentials for basic authentication

request.add\_header("Authorization", "Basic {}".format(auth))  
request.add\_header("X-Atlassian-Token","no-check")

# Build the request body

body = b''  
body += b"--" + boundary + b"\r\n"  
body += b"Content-Disposition: form-data; name="file"; filename="{}"\r\n".format(os.path.basename(file\_path))  
body += b"Content-Type: multipart/form-data;boundary:{}\r\n\r\n".format(boundary)  
body += file\_data  
body += b"\r\n--" + boundary + b"--\r\n"

# Set the request method and data

request.get\_method = lambda: 'POST'  
request.add\_data(body)

# Send the request

response = urllib2.urlopen(request)  
print response.getcode()  
print response.info()

---

<div class="post-metadata">

**Author:** ![Akhil\_Mattam](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@Akhil\_Mattam](https://forum.inductiveautomation.com/u/Akhil_Mattam)\
**Post date:** [September 28, 2023, 10:52am UTC](https://forum.inductiveautomation.com/t/adding-attachments-to-jira-issues/79743/2 "2023-09-28T10:52:55Z")

</div>

Even i'm facing the same issue...could anyone help..!
