Java.lang.illegalargumentexception Illegal Character In Url
i want to request into web service my parameter like this urlString = http://ip/autodownload/andro.php?key=apps.apk|2|bla.bla.bla public void getRequest(String Url) { Toast.m
Solution 1:
Try encoding Your URL
String link="http://example.php?string1="+URLEncoder.encode(string1)+"&string2="+URLEncoder
.encode(string2)+"&string3="+URLEncoder.encode(string3)+"&string4="+URLEncoder.encode(string4)+"";
Solution 2:
Check this
String myurltoencode = "http://ip/autodownload/andro.php?key=apps.apk|2|bla.bla.bla";
URLEncoder.encode(myurltoencode,"UTF-8");
Solution 3:
In my case it was the variable that I was appending that caused the problem. It had an extra space (spaces). I trimmed it and the error went away. "http://somewebsite.com/somefile?q="+someVariable.trim()
Solution 4:
This worked for me. Suppose you have illegal character inside your IP address. Then convert it into Base64 code and send to your server.
For example:
String ip_address = StaticClass.getIPAdress();
try {
// Sending side
byte[] data = ip_address.getBytes("UTF-8");
ip_address = Base64.encodeToString(data, Base64.DEFAULT);
} catch (Exception e) {
e.printStackTrace();
ip_address = "";
}
Write encode ip_address or any field you want inside your url. Decode the variables at your server. But i'm not sure if you are using : com.loopj.android.http.AsyncHttpClient.get
vkj
Post a Comment for "Java.lang.illegalargumentexception Illegal Character In Url"