@converted to% 40 in HTTPPost request

im trying to send a mail request to webservice .. when i add the special @ character in the parameter, it closes until% 40.i checked the server side. They get% 40 instead of @. Can someone help me ?? here is my code ..

httpclient = new DefaultHttpClient(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("Email", " abc@gmail.com ")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = httpclient.execute(httppost,responseHandler); 

I also tried this method to prevent my parameter from coding.

 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.PLAIN_TEXT_TYPE)); 

but he picked up an unsupported encoded algorithm

Pls help me with this.

+6
source share
4 answers

You are using UrlEncodedFormEntity , which will be the URL encode . Turning @ to %40 is normal with this encoding. The recipient should be able to decode this automatically, although for this you may need the right type of content, perhaps application/x-www-form-urlencoded .

+6
source

Use URLDecoder.decode(url) , it will be useful.

+3
source

You need to use something like URLDecoder on your server side so that you can convert %40 back to @ , The same goes for other special characters.

+2
source

you can use

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

remove any special character from the URL that is passed

+1
source

Source: https://habr.com/ru/post/907935/


All Articles