• FJDEV
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
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()); ( return 'DE' as result)
 String Country = (String)res.getBody();
System.debug('the return value is'+Country); ( 'DE' as result )

ISOContry__c cs = ISOContry__c.getInstance(Country);
System.debug(cs); ( return null as result)
System.debug (' the A3 '+ cs.A3__c); ( Attempt to de-reference a null object)



      But when I try just to give the value as String  it is working so that's mean that the custom setting has the name 'DE' ! so really I don't understand what could be the problem

ISOContry__c cs2= ISOContry__c.getInstance('DE');
System.debug(cs2.A3__c); (it is working as expected)

 
  • September 19, 2018
  • Like
  • 0
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()); ( return 'DE' as result)
 String Country = (String)res.getBody();
System.debug('the return value is'+Country); ( 'DE' as result )

ISOContry__c cs = ISOContry__c.getInstance(Country);
System.debug(cs); ( return null as result)
System.debug (' the A3 '+ cs.A3__c); ( Attempt to de-reference a null object)



      But when I try just to give the value as String  it is working so that's mean that the custom setting has the name 'DE' ! so really I don't understand what could be the problem

ISOContry__c cs2= ISOContry__c.getInstance('DE');
System.debug(cs2.A3__c); (it is working as expected)

 
  • September 19, 2018
  • Like
  • 0