i m trying to send post request to webservice.. when i add special character @ in parameter it is coverted to %40.i have checked server side..they are getting %40 instead of @. can any one help me?? here is my code..
httpclient = new DefaultHttpClient();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("Email", "[email protected]"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httppost,responseHandler);
i have also tried this method to prevent my parameter from encoding.
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.PLAIN_TEXT_TYPE));
but it raised unsupported encoded algorithm
pls help me out of this.
"%40" in a URL means "@". If you want a "%" to mean "%", you need to URL encode it to "%25". URL encoding is just a transport encoding. If you feed in "@", its transport encoded version is "%40", but the recipient will get "@" again.
You're using UrlEncodedFormEntity
, which will URL-encode the content. Turning @
into %40
is normal with this encoding. The recipient should be able to decode that automatically, although you may have to use the correct content type for it to do so, probably application/x-www-form-urlencoded
.
You can use
URLDecoder.decode("urlcontext", "UTF-8");
to remove any special character from the url which your passing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With