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
Kamal BollineniKamal Bollineni 

Integration API

I am new to Integrations and trying to integrate with the 3rd party URL - Kindly provide me the sample snippet code how to write 
in APEX with REST/SOAP Integration. The question is "to fetch all the needed data and insert & update(infuture)
in our custom fields of an object from the URL "www.xyz.com.json" I have already parsed, As well I need to update the records in 
future without overrding of the existing data, and alongside which is the best option for updating the records in future for every 90days 
(either Schedule APEX or Future method) from the above said URL".

public class XXXXClass { 
    Public void <MethodName>() {
        string url = 'https://www.XYZ.com.json'; 
        Http http = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(url); 
        req.setMethod('GET'); 
        HttpResponse res = http.send(req); 
        if(res.getStatusCode() == 200){ 
            system.debug('response'); 
            map<string,object> resp=(map<string,object>) json.deserializeUntyped(res.getBody()); 
            system.debug(resp); 
        }
    }
}
Best Answer chosen by Kamal Bollineni
VinayVinay (Salesforce Developers) 
Hi Kamal,

You can use batch apex to trigger API callout to external system for every 90 days in salesforce

Check below examples.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
https://focusonforce.com/development/batch-apex-in-salesforce/
https://developer.salesforce.com/forums/?id=9060G000000XgipQAC

Please mark as Best Answer if above information was helpful.

Thanks,