Forums

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

How to solve this no multipart boundary was found while trying to send attachment via rest call ?

abhinay006 April 11, 2017

I am getting following error while sending attachment to created issue on JIRA. 


<message>org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found</message><stack-trace>java.lang.RuntimeException: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

I am making an ajax call to send this attachment as multipart-data. 

var blob = canvasImageDataUrl
var fd = new FormData();
fd.append("file", blob,"ss_"+issueKeyid+".png");

$.ajax({
url: "https://"+jiraUrl+"/rest/api/2/issue/"+issueKeyid+"/attachments",
type: 'POST', 
data: fd,
processData: false,
beforeSend: function (xhr) {
xhr.setRequestHeader ("X-Atlassian-Token", "no-check");
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.setRequestHeader("charset", "UTF-8");
},
success: function(data) {
alert("issue created");

},
error:function(data){
console.log(data);
},
complete:function(xhr,status){
console.log(xhr);
}
});



 

1 answer

1 vote
Blake April 12, 2017 edited

Try eliminating this: 

xhr.setRequestHeader("Content-Type", "multipart/form-data");

And add this:

contentType: false,

 

Also, you will need to add a comment and minorEdit to your file data otherwise it won't work. So add this before the ajax request:

fd.append('comment', "foo");
fd.append('minorEdit', "true");

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events