In android I have a parameter that is the list of days that is converted into a Byte array, and then Base64 to be passed to a webservice in URL as:
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
// Saving the days selected (but also allowing none)
oos.writeObject(event.getChosenDays());
buff = bos.toByteArray();
encoddedDaysString = Base64.encodeToString(buff, Base64.DEFAULT);
} catch (Exception e) {
}
String CreateEvent = "http://" + Global.getFeastOnline()
+ "/createEvent" + "/"
+ "0" + "/"
+ "-1" + "/"
+ "-1" + "/"
+ event.getAlarmActive().toString() + "/"
+ "0" + "/"
+ event.getAlarmTimeString() + "/"
+ encoddedDaysString + "/"
+ "0" + "/" // Should not pass tone to path
+ event.getVibrate().toString() + "/"
+ event.getAlarmName() + "/"
+ event.getAlarmDateString()
+ ".json";
However, upon executing a GET request, it errors out. Then, checking the logs, it appears that a very large space is added to the converted string, thus breaking the URL:
08-02 16:13:17.184 11663-11663/ D/Create Events Error? com.android.volley.NoConnectionError: java.net.ProtocolException: Unexpected status line: <!DOCTYPE html>
08-02 16:14:09.204 11663-11663/ V/Create Events Error? user_id: 2
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_active: true
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_time: 16:03
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_days: rO0ABXVyADNbTGNvbS5leGFtcGxlLmZlYXN0YXBwLk1haW5NZW51Lk15RXZlbnRzLkV2ZW50JERh
eTuousH0g5N2ggIAAHhwAAAAAA==
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_tone: 0
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_vibrate: true
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_name: Event Clock
08-02 16:14:09.204 11663-11663/ V/Create Events Error? event_date: 2015-08-03
08-02 16:14:09.204 11663-11663/ V/Create Events Error? createEven: http://(IPADDRESS):3000/createEvent/0/-1/-1/true/0/16:03/rO0ABXVyADNbTGNvbS5leGFtcGxlLmZlYXN0YXBwLk1haW5NZW51Lk15RXZlbnRzLkV2ZW50JERh
eTuousH0g5N2ggIAAHhwAAAAAA==
/0/true/Event Clock/2015-08-03.json
I have tested in browser the removal of this space, and everything works fine with the web-service.
How can this space be removed without destroying the validity of the Base64 conversion?