How to: Create attachment in JIRA using POST doHTTPRequest via JS

In need of urgent help, am trying to create an attachment on a jira issue through POST doHTTPRequest via javascript from my app service manager. But getting Error 500. Can someone help me with the script or let me know what’s happening?

function doAttachOut(httpAction,url,binaryData,timeout,attachmentObj,param,attchmentName) {
     var JSON = system.library.JSON.json(); 
     var headers= new Array();
     headers.push(new Header("Authorization",  "Basic token")); 
     headers.push(new Header("X-Atlassian-Token", "no-check"));
     headers.push(new Header("Content-Type", "multipart/form-data"));
     headers.push(new Header("Accept", "application/json"));  
     headers.push(new Header("Content-Disposition", "attachment;file=@"+attchmentName));
    try {
        var respHeaders = new Object();
        var resp = doHTTPRequest(httpAction, url, headers, binaryData, 20, 20, null, respHeaders);
        //var resp = doHTTPRequest(httpAction, url, headers, null, 20, 20);
        var objResponse = JSON.parse(resp);
        print("Messages: \n"+objResponse.Messages.join("\n"));
        print("Return Code: "+objResponse.ReturnCode); 
        print("Attachment Name: "
    catch( cError ) 
        print("ERROR: \n"+cError);
  return resp;


Ok, now the error is 415 unsupported media type. What could this be?
Am trying to send a txt file and setting the Content-Type header to ‘text/plain’.
However, works fine when using curl.