function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinay_guptaVinay_gupta 

Invocable method to get record and store the response in wrapper

Hi All,

I am new to Salesforce integration. I have to write an invocable method that will get records from an external system. I have endpoint URL and parameter. I want to store the result in wrapper response.
I have tried this but was not able to get the exact code.

public class fetchdetails{
@InvocableMethod
public static List<Results> FetchZillowEstimation(List<Results> address)
    {
    HTTP h = new HTTP();
    HTTPRequest req= new HTTPRequest();
    req.setEndpoint('https://api.getfurnituredata.com/?address=test');
    req.setMethod('GET');
    HTTPResponse res= h.send(req);
    if (res.getStatusCode() == 200) {
            String jsonInput =res.getBody();;
        }
    System.debug(res.getBody());
    String jsonInput =res.getBody();
    Map<String,Object> m =(Map<String, Object>) json.deserializeUntyped(jsonInput);
    system.debug(m);
    }
    
      

}
global class Results{
@InvocableMethod
global decimal name;

}
 
Harshad ChauhanHarshad Chauhan
String jsstring='{"FRAPI":{"STATUS":"0","MSG":" ","ACCOUNTLIST":{"ACCOUNT":[{"ACCOUNTID":"1083302481D3","ACCOUNTNAME":"Teddy Roosevelt","DEFAULTDATE":"20121231"},{"ACCOUNTID":"119334261AD3","ACCOUNTNAME":"Stephen King","DEFAULTDATE":"20121231"}]}}}';

system.debug((cls_FRAPI) System.JSON.deserialize(jsstring, cls_FRAPI.class));

    public class ACCOUNT {
        public String ACCOUNTID;
        public String ACCOUNTNAME;
        public String DEFAULTDATE;
    }

    public class cls_FRAPI {
        public FRAPI FRAPI;
    }

    public class ACCOUNTLIST {
        public List<ACCOUNT> ACCOUNT;
    }

    public class FRAPI {
        public String STATUS;
        public String MSG;
        public ACCOUNTLIST ACCOUNTLIST;
    }






That should help