Not able to download excel data from server

I am trying to download the data from an API, which is sending the data content-type as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, the file gets corrupted not able to open…if I change the name to csv of same file then I can see the binary data…

When I hit the request from postman and save the response…the file gets open without any issue…

Hi there!!! Sorry you’re facing this issue.
When you can you share a screenshot of what your download function call looks like for application/vnd.openxmlformats-officedocument.spreadsheetml.sheet file type?

image
@pranav

when i save the response from postman the data file is 183kb…
but when i download the file from appsmith it reduced to 172kb

Hi! Can you share a screenshot of the response returned by the bankStatementDownloadAPI API?

Hello, I’m having a similar problem. Did you find a solution?

Hello @Jonathan0 and welcome to our community! What is your Appsmith version? Could you please send some screenshots of your implementation and the error you are getting?

Hello Amelia.

I’m getting a xlsx file from my own C# API:

return File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", name); 

And in appsmith I just want to be able to download it. I tried copying an example code in the dcoumentation. I can see the body data from the request seems also odd.

It downloads the file fine but when I try to open it in excel it’s corrupt. It works fine with postman and trying with the swagger so it’s not the API.

Hi Jonathan!
I’ve logged this issue internally. I or someone from the team will reach out to you once we have any useful information!

Hello,

I logged the GetXSLX.data.length and it’s always a bit smaller that the request response body and Content-Length.

As the original poster commented, my files are also always a bit smaller than with postman. It seems it’s truncating a bit of the data between the request response body and the data variable.

I am now simply trying with:
download(GetXLSX.data, “TestFile.xlsx”);

I found a temporary fix. My API now returns the file as Base64 encoded field and in appmisth I decode it:

download(atob(GetXLSX.data.data), "Test.xlsx",'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

And at least it’s working :slight_smile:

Hi there!
We’re still working on a permanent fix for this issue.
Someone from the team will definitely reach out to you for further updates.
Thank you for your continuous support

Hello @Jonathan0! Can you please share this app with us to debug this scenario? Add support@appsmith.com as a Developer and send us the link to it.

Hello @Jonathan0
You can use the following to download your file:

downloadApiFile: async ()=> {
   const reader = new FileReader();
   reader.readAsDataURL(File);
   reader.onload = async function () {
		 await download(reader.result,"fileName with extension", "file mime type")	 
   };
},