Forums

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

Add attachment to issue with jira api without using curl

Bastet DT
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 17, 2019

I'm trying to add an attachment to some Issue that I created through the Jira API. 

On the documentation there is only a curl example but I can't install this for some reason. I just want to know what the request would look like wo curl. I'm using for my website in php.

2 answers

0 votes
Kais Tounsi July 17, 2019

hi here you find the python script 

how to upload attachment to an Issue using the REST API in Python

If you find this answer useful, I would kindly ask you to like and share it so the same will be visible to others who might be facing the same issue you have inquired.Thank you for your understanding.

 

# ===============
# greeting.txt
# ===============
hello, world
 
# ===============
# upload.attachment.py
# ===============
import requests
import json


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

...........................
0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 18, 2019

Hi @Bastet DT ,

The curl example is just intended to show what needs to be provided when sending an HTTP POST request to the Jira REST API endpoint in order to add an attachment to an issue. You can just provide the same data in any other way without using curl. 

In the below threads you can find examples showing how to add an attachment using PHP or Java or python. Just keep in mind that there are differences depending if you are using Jira Cloud or Server (e.g. In Cloud you must use email address and api-token instead of username and password to authenticate):

 

Please review above threads and let us know if they help. In case they don't please try to provide more details  on what you are trying to achieve.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer