Response(xls file) of a POST Rest is corrupted using fileSaver.js 's saveAs method(Javascript)

Below is the detail of JAVA rest service which downloads a file from server: Method prototype:

@POST@Path("/prop/export")@Produces(MediaType.APPLICATION\_OCTET\_STREAM)@Consumes(MediaType.APPLICATION\_JSON)publicResponse exportItemsToFile(Map\<String,String\> params);

The Response is build from byte array in its implementation:


I am using FileSaver.saveAs to download the response in a xls file using below code

var requestUri ='/wtk/rc/v1/pfm/prop/export'; var payload={"context":addCtx,"language":addLang,"country":addCountry,"swimlane":addSL}; $, payload,{ headers:{'Content-Type':'application/json'}, responseType:'arraybuffer',}).success(function (data){ var blob =newBlob([data],{type :'application/'}); var fileName = addLang+"\_"+addCountry+".xls"; filesaver.saveAs(blob,fileName);}).error(function (){//download failed});

The response which is xls file is corrupt using the above code. **

It is because the promise returned by $ have blank response in case of if rest client produces octet-stream


But if I use some rest client like Postman, and select “Send and Download” option and save the response as xls. It is coming up fine.

Any help in this will be appreciated.


I have axactelly the same issue. Did you get it working ?

Any help will be appreciate.