I'm trying to get a zip file using DownloadManager parsing a cookie with a JSESSIONID from my server. I'm getting this JSESSIONID doing all my process login using HTTPCLIENT lib and setting a variable JSESSIONID for later use in my DownloadManager request.
My download request:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(htmlUrlDownload));
request.addRequestHeader("Cookie", "JSESSIONID=" + JSESSIONID);
request.addRequestHeader(Constants.USER_AGENT, Constants.TARGET_REQUEST_HEADER);
request.setDescription("Baixando " + metaDado.getType());
request.setTitle("Download");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
String nameFile = offlineUuid + ".zip";
fileName = nameFile;
filePath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DOWNLOADS
+ File.separator + fileName;
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, nameFile);
final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
final long downloadId = manager.enqueue(request);
The problem is that download never starts and the COLUMN_REASON returns a code to ERROR_UNHANDLED_HTTP_CODE
But if I try to download the same file using a dropbox link without authentication or using httpclient, it's works perfectly, what am I doing wrong?
How can I get a better msg error?