This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

UTF8 URL ENCODING

0

Hi, I am calling a nominatim WS through a Java client using this piece of code:

String urls = "http://nominatim.openstreetmap.org/search?q= " + URLEncoder.encode(addressString.trim(), "UTF-8") + "&format=json&polygon=1&addressdetails=1";
URL url = new URL(urls);            
HttpURLConnection uc = (HttpURLConnection) url.openConnection();            
uc.setRequestProperty("Accept-Charset:", "UTF-8");
uc.setRequestProperty("Content-Type:","application/x-www-form-urlencoded;charset=utf-8");

But i got this error:

'406: Not Acceptable' for url: 'http://nominatim.openstreetmap.org/search?q= %CE%A0%CE%91%CE%A1%CE%99%CE%A3%CE%99&format=json&polygon=1&addressdetails=1'

Thanks and best Regards,

asked 05 Aug '15, 09:49

ricard_3's gravatar image

ricard_3
71114
accept rate: 0%

edited 05 Aug '15, 10:36

scai's gravatar image

scai ♦
33.3k21309459


One Answer:

3

removing the white space after q "q= " has solved the problem. Thanks

answered 05 Aug '15, 10:37

ricard_3's gravatar image

ricard_3
71114
accept rate: 0%

Source code available on GitHub .