Add attachment to an issue using JQUERY


Will appreciate some assistance here please...

We have been able to use the below JSON file to open up an issue in JIRA.

However, we want to take this a step further... We will like to add an attachment to this issue, either via:

1. When issue is originally opened usig below JSON file.


2. Use the issue number created from below file, to add an attachment to issue.

"fields": {
{ "name": "Letter of Greeting" }
{ "key": "CCOPS" }
"customfield_10063": "City/Town",
"customfield_10101": "Charitable Organization Number",
{ "value": "Pending" }
{ "value": "Pending" }
"customfield_10102": "URL",
"labels": [ "greeting" ],
"customfield_10103": [
{ "value": "By clicking this button I confirm that I am the Official Representative of the Organization requesting the Proclamation" }
"customfield_10016": "Organization Name",
"customfield_10017": "Event Name",
"customfield_10018": "2016-11-28",
{ "value": "Convention" }
{ "name": "mhelly", "key": "mhelly" }
"description": "Description",
"customfield_10011": "Province",
"customfield_10012": "Postal Code",
"customfield_10014": "Additional Notes",
"customfield_10015": "2016-11-27",
"customfield_10005": "Telephone Number",
"summary": "Please enter a summary for this Service Request.",
"customfield_10081": "Street Number",
"customfield_10082": "Street Name",
"customfield_10083": "Unit Number",
"customfield_10084": "First Name",
"customfield_10085": "Last Name",
"customfield_10086": "Email@Email.Email",
{ "name": "CCO_Webmaster", "key": "CCO_Webmaster" }

1 answer

Hi Volodymyr,

I looked to curl command  but 

my point is to use JQUERY to get this job done.

Here is my code:

var formdata = new FormData();
formdata.append('tasks', "C:\01-Rosana-Protocol\NOV-2016\Tasks10.txt");
formdata.append('tabs', "C:\01-Rosana-Protocol\NOV-2016\chroom tabs10.txt");
_.forEach(formdata.entries(), function (value, key) {
for (var k in formdata.entries()){
console.log(k[0]+ ', ' + k[1])

$.support.cors = true;
type: "POST",
url: "",
data: formdata,
contentType: false,
processData: false,
headers: {
"X-Atlassian-Token": "nocheck"

// contentType: "multipart/form-data; boundary=HereGoes",
contentType: "multipart/form-data",
success: function (data, status, req) {
alert("Data Loaded : " + data);
error: function (jqXHR, textStatus, errorThrown) {
alert('responseText ' + jqXHR.responseText);
alert('error in uploading:: ' + errorThrown);


After executing this AJAX call I got nothing uploaded into JIRA isssue


Thanks for your help

I never did multipart file upload via jQuery and I guess it's restricted by due to security reasons. Please debug your request to check if files are actually send.

Please consider doing this via html form.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

222 views 6 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you