We have a java application which sends sms. We have 2 two variable set as below.Then it goes through an encoding process. The problem now it works fine but after the &Time…. the message is not delivered? So what other encoding mechanism should I work on?
String smsMessage = "Asset:TEST1\nSerial ID:Test1\nEvent:Arrive\nDate&Time:2012-04-26 21:06:37\nEvent Location:Location1";
String fullMessageLink="user=tt1&password=tt11&api_id=2211&to=1234567&text="+smsMessage;
URI uri = new URI(
"http",
"api.clickatell.com",
"/http/sendmsg",
fullMessageLink,
null);
String request = uri.toASCIIString();
The ampersand
&is used as the separator between URL parameters. Notice the&'sin thefullMessageLink. To pass a string with an&it is you need to URL encode the value.Use the URLEncoder class to perform the encoding.