1

In my Android app, which fetches JSON data from an URL, I have to encode the username and password. If I encode my username and use it in my URL, it throws an Invalid characters at path error. However if I try the URL with the encoded username, it works! I tried to URLEncode the URL and the username part itself, that gives me an internal server error.

not encoded String username: lc118820, Base64 encoded String username: bGMxMTg4MjA=

            // Encrypting username and password
    username = Base64.encodeToString(username.getBytes(), 0);
    byte[] byteArray = DigestUtils.sha1(password);
    password = Base64.encodeToString(byteArray, Base64.NO_WRAP);
    password = new String(Hex.encodeHex(password.getBytes()));

    getleerlingidurl = "http://somtoday.nl/" + schoolname + "/services/mobile/v10/Login/CheckMultiLoginB64/" + username + "/" + password + "/" + brin;

:EDIT: I found a solution! I changed username = Base64.encodeToString(username.getBytes(), 0); to Base64.encodeToString(username.getBytes(), Base64.NO_WRAP);

Cœur
  • 34,719
  • 24
  • 185
  • 251
anned20
  • 576
  • 1
  • 4
  • 19

0 Answers0