Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@ converted to %40 in HTTPPost request

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.

like image 641
Nirav Bhandari Avatar asked Feb 08 '12 12:02

Nirav Bhandari


People also ask

What does %40 mean in a URL?

"%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.


2 Answers

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.

like image 188
Bruno Avatar answered Sep 20 '22 23:09

Bruno


You can use

URLDecoder.decode("urlcontext", "UTF-8");

to remove any special character from the url which your passing

like image 22
Rajesh Avatar answered Sep 19 '22 23:09

Rajesh