I\'m having problems with downloading binary file (zip file) in my app from te internet. I have to use basic access authentication to authorize acces to file, but server respons
I might be a bit late but I just came across a similar problem. The problem lies in the following line:
String encoding = Base64.encodeToString(authentication.getBytes(), 0);
If you change that line to look like this it should work:
String encoding = Base64.encodeToString(authentication.getBytes(), Base64.NO_WRAP);
By default the Android Base64 util adds a newline character to the end of the encoded string. This invalidates the HTTP headers and causes the "Bad request".
The Base64.NO_WRAP flag tells the util to create the encoded string without the newline character thus keeping the HTTP headers intact.