GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Reverse Geocoding Webservices : Country  XML
Forum Index -> General
Author Message
ilumefiras



Joined: 19/09/2018 16:50:44
Messages: 1
Offline

trying to find the ISO country code for the given lat/lng.

I didn't get a String . I get an error "Unexpected character" and I can not inser the response in my database ! using this method: http://api.geonames.org/countryCode?lat=52.42452&lng=10.7815&username=** I thought we get a text as response !

I've certainly missed something?
here is my code :

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://api.geonames.org/countryCode?lat=52.42452&lng=10.7815&username=***');
req.setHeader('Content-Type', 'text/html');
req.setMethod('GET');
HttpResponse res = h.send(req);
System.debug('country' + res.getBody());
String Country = (String)res.getBody();
System.debug('the return value is'+Country);

ISOContry__c cs = ISOContry__c.getInstance(string.valueOf(res.getBody()));
System.debug(cs);
System.debug (' the A3 '+ cs.A3__c);
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team