I am using method 2 to download excel files from my server. it works as expected when download is successful.
However, if for whatever reason, if unsuccessful, the downloaded file would be in html format with the error for example,
`<HTML<HEAD
<TITLEAccess Denied</TITLE
Thanks. I used an int for the status code property in the http request, and do an if else check, such that if status code != 200, it will delete the file, and if =200, continues with the rest of the program.