Note: I am using python.
I am trying to create an issue using the API that has a CSV file as an attachment.
I have done some research and it seems I need to create the issue, then update the issue and add the attachment.
I am able to create an issue with no problem. However, when I go to add the CSV file, I am getting a 404.
Here is my code for adding the csv to my issue. I store the id of the issue I created into a dataframe. My auth is correct - I have just ommitted it for this post.
files = {'file': open('myfile.csv', 'rb')}
url="https://mydomain.atlassian.net/rest/api/2/"+str(df.iloc[0]['id'])+"/attachments"
headers = {
"Accept": "application/json",
"Content-Type": "multipart/form-data",
"X-Atlassian-Token": "no-check"
}
response = requests.request(
"POST",
url,
headers=headers,
auth=auth,
files=files
)
Any help would be greatly appreciated!
I found the solution for others reference. This is the full code that is used with the exception of omitting the auth values.
files = {
'file': (myfile.csv, open(myfile.csv, 'rb')),
}
url="https://mydomain.atlassian.net/rest/api/2/issue/{id}/attachments"
headers = {
"Accept": "application/json",
"X-Atlassian-Token": "no-check"
}
response = requests.request(
"POST",
url,
headers=headers,
auth=auth,
files=files
)
The first issue was I needed to add "/issue/" into my URL before the id of the issue. Secondly, I needed to remove "Content-Type": "multipart/form-data" from my header values.
I hope this helps others!
Do you know how to use python to attach a pdf file into a jira issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
there's a framework called pyjira which provides an easier method to create and attach an attachment easily into an issue in python. Something worth considering, however your example code here is incomplete and guessing what you're trying to do isn't really troubleshooting. I will suggest you show a proper snippet of your code and what you've done so far. something you know you can publicly display here on community and we can examine it to see what's wrong with it and expand on it if necessary.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.