Skip to main content
extending the sample
Source Link

You have to deserialize the response body you are getting. To achieve that you need to use the apex JSON lib.

From my view the easiest method is use json.deserializeUntyped

Sample

    Http h = new Http();
    Httpresponse resp = h.send(req);
    system.debug('resp:'+resp);
    system.debug('respBody:'+resp.getBody());
    Map<String,Object> jsonResp = (Map<String,Object>) JSON.deserializeUntyped(resp.getBody());
    Map<String,Object> res = (Map<String,Object>) jsonResp.get('QueryResult');
    List<Object> results = ((List<Object>)) results.get('Results');

    for(Map<String,Object> r: results){
       system.debug('NAme: '+r.get('Name'));
       system.debug('State: '+r.get('State')); 
        //rest ..... 
    }

You have to use json.deserializeUntyped

Sample

    Http h = new Http();
    Httpresponse resp = h.send(req);
    system.debug('resp:'+resp);
    system.debug('respBody:'+resp.getBody());
    Map<String,Object> jsonResp = (Map<String,Object>) JSON.deserializeUntyped(resp.getBody());
    Map<String,Object> res = (Map<String,Object>) jsonResp.get('QueryResult');
    List<Object> results = ((List<Object>)) results.get('Results');

    for(Map<String,Object> r: results){
       system.debug('NAme: '+r.get('Name'));
       system.debug('State: '+r.get('State')); 
        //rest ..... 
    }

You have to deserialize the response body you are getting. To achieve that you need to use the apex JSON lib.

From my view the easiest method is use json.deserializeUntyped

Sample

    Http h = new Http();
    Httpresponse resp = h.send(req);
    system.debug('resp:'+resp);
    system.debug('respBody:'+resp.getBody());
    Map<String,Object> jsonResp = (Map<String,Object>) JSON.deserializeUntyped(resp.getBody());
    Map<String,Object> res = (Map<String,Object>) jsonResp.get('QueryResult');
    List<Object> results = ((List<Object>)) results.get('Results');

    for(Map<String,Object> r: results){
       system.debug('NAme: '+r.get('Name'));
       system.debug('State: '+r.get('State')); 
        //rest ..... 
    }
Source Link

You have to use json.deserializeUntyped

Sample

    Http h = new Http();
    Httpresponse resp = h.send(req);
    system.debug('resp:'+resp);
    system.debug('respBody:'+resp.getBody());
    Map<String,Object> jsonResp = (Map<String,Object>) JSON.deserializeUntyped(resp.getBody());
    Map<String,Object> res = (Map<String,Object>) jsonResp.get('QueryResult');
    List<Object> results = ((List<Object>)) results.get('Results');

    for(Map<String,Object> r: results){
       system.debug('NAme: '+r.get('Name'));
       system.debug('State: '+r.get('State')); 
        //rest ..... 
    }