FormData empty while AJAX POST with PDF : SAPUI5
I am trying to use a document info extraction API which takes PDF/JPEG along with "options" json object as FormData. I tried forming the data and do an AJAX Post but it returns 400 error "message": "Required form-data not provided." and the FormData object looks like an empty object with content type as "application/x-www-form-urlencoded". From Postman, I see that the content type should be multipart/formdata with boundary.
var fileuploader=this.byId("fileUploader"); //var fileB = new File( fileA, 'canvasImage.png',{ type: 'image/png' } ); jQuery.sap.domById(fileuploader.getId() + "-fu").setAttribute("type", "file"); data1.append("file",jQuery.sap.domById(fileuploader.getId() + "-fu").files[0]); var blob = new Blob([JSON.stringify(options)], {type : 'application/json'}); data1.append("options",blob); jQuery.ajax( { url: "/DIC_trial_API/document/jobs", data: data1, "headers": { "Content-Type":undefined, // // "Accept":"*/*", "Authorization": "Bearer "+bearerToken }, cache: false, //contentType: false, processData: false, method: 'POST', success: function(data) { console.log(data); }, error: function(err) { console.log(err); } });
Is something wrong with formdata or the post method used?