I am getting this error when I use HttpClient. I have looked at many answers from SO but none seem to answer mine. Here in the URL I have URLEncoded only the message. I can't for the world figure out the illegal character. The other answers have a special character like "{" or "|" in the URL. There are none in mine. Yet I get the exception. I am at my wits end.
Here is the Stack trace:
java.lang.IllegalArgumentException: Illegal character in query at index 95: http://api.alerts.sinfini.com/v3/index.php?method=sms&api_key=XXXXXXXX&to=1234567890&sender=SIDEMO&message=Oyeseva+Registration+Verification+Code%3A+366509&format=json&custom=1,2&flash=0
at java.net.URI.create(URI.java:859)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:69)
at com.oyeseva.messaging.SMSSender.sendSMS(SMSSender.java:58)
at com.oyeseva.messaging.SMSSender.send(SMSSender.java:104)
at com.oyeseva.messaging.alerts.SendMesssageOrEmail.alertIsAnSMS(SendMesssageOrEmail.java:71)
at com.oyeseva.messaging.alerts.SendMesssageOrEmail.run(SendMesssageOrEmail.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Edit: I have used URLEncoder to encode the whole URL but it chokes on errors. Also tried encoding the query only..says the method is missing...the method is sms here in the URL.