GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Java API 403 Error  XML
Forum Index -> General
Author Message
ykcorse



Joined: 21/12/2012 10:32:06
Messages: 2
Offline

Hello,

I found out today about this service, impresive tool, and I tried to add it to a java aplication, by using the api provided, but I get all the time the same 403 error:

java.io.IOException: Server returned HTTP response code: 403 for URL: http://api.geonames.org/search?q=malaga&username=jrgu

For me it is weird, because when I input the url in the browser it works correctly, is this normal?

I wrote the code given in the exmaple:

Code:
 	/**
 	 * @param args
 	 */
 	public static void main(String[] args) {
 		// TODO Auto-generated method stub
 		List<Toponym> toponymsList = new ArrayList<Toponym>();
 		try {
 			setProxy();
 			WebService.setUserName("jrgu"); // add your username here
 			ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
 			searchCriteria.setQ("malaga");
 			ToponymSearchResult searchResult = WebService
 					.search(searchCriteria);
 			toponymsList = searchResult.getToponyms();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 	}
 


Thanks,
Joaquín
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

Joaquín

You have a line "setProxy();" in your code. This is most likely the cause of your problems, that your proxy is not working properly.

Best Regards

Marc

[WWW]
ykcorse



Joined: 21/12/2012 10:32:06
Messages: 2
Offline

Thank you Marc! for some reason I can not get it to work behind a proxy, but it works perfectly when there is no proxy.
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team