How to send one or multiple attachment with rest api

How to send one or multiple attachment with rest api when creating issue.

I'm am able to create issue with project id but not getting how to attach file or images when creating issue.

will be gratefull.

1 answer

This widget could not be displayed.

Look for "attachments" and POST in the API doc. You'll need to call the post once for each attachment https://docs.atlassian.com/jira/REST/latest/

Thanks Nic Brough,

I tried that but i'm getting error internal server error.

Please see the code & tell me what i'm doing wrong in this.

<script type="text/javascript">

function Upload() {

jQuery.support.cors = true;

var param2 = "{\"file\": \"D:\Vaibhav\Jira_Rest_Api\Uploads\LoanE1.jpg\", \"mimeType\": \"image/jpeg\",\"content:\":\"D:\Vaibhav\Jira_Rest_Api\Uploads\LoanE1.jpg\"}";

$.ajax({

type: "POST",

url: "http://10.0.1.62:1001/rest/api/2/issue/Demo-88/attachments",

dataType: "json",

processData: false,

data: param2,

contentType: "Content-type: multipart/form-data",

success: function (data) {

alert("Data Loaded auth: " + data);

window.open("jira_Login1.htm");

},

error: function (jqXHR, textStatus, errorThrown) {

alert('error in uploading:: ' + errorThrown);

}

});

}

</script>

You don't seem to be iterating through the attachments, just throwing them all at it in one go. Can you try one at a time?

Yes i tried for only single attachment. I did that by jquery.I pasted the code above . But still getting "internal server error".

Is this server problem or mine don't know?

Um, it looks like your code is setting param1 to a set of files, but then posting the whole set in one go. Could you try posting a single file?

I'm posting only single file ....

till now i did not try for multiple attachments.

Please Suggest me, why i'm unable to send attachment with Rest API.

It is giving me "Internal Server Error" when i try to send attachment.

Here I'm trying to send single attachment when creating issue.

Code is given below.

.

<script type="text/javascript">

function Upload() {

jQuery.support.cors = true;

var param2 = "{\"file\": \"D:\Vaibhav\Jira_Rest_Api\Uploads\LoanE1.jpg\", \"mimeType\": \"image/jpeg\",\"content:\":\"D:\Vaibhav\Jira_Rest_Api\Uploads\LoanE1.jpg\"}";

$.ajax({

type: "POST",

url: "http://10.0.1.62:1001/rest/api/2/issue/Demo-88/attachments",

dataType: "json",

processData: false,

data: param2,

contentType: "Content-type: multipart/form-data",

success: function (data) {

alert("Data Loaded auth: " + data);

window.open("jira_Login1.htm");

},

error: function (jqXHR, textStatus, errorThrown) {

alert('error in uploading:: ' + errorThrown);

}

});

}

</script>

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

121 views 2 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