Posts

Showing posts with the label Webservice callout from Scheduled Apex salesforce

Webservice callout from Scheduled Apex

Making webservice callout from Schedulable classes Ever faced the error " System.CalloutException: Callout from scheduled Apex not supported. " This is the error you get when you are making a webservice callout from a class which is implementing Database.Schedulable interface. Salesforce does not allow you to make callouts from Schedulable classes. So I had this requirement where I needed to schedule a piece of code which was making a callout to external websrvice. This is my schedulable class : public class ExampleScheduler implements Schedulable{        public void execute(SchedulableContext SC) {       ExampleHelper.makeWebserviceCallout();    } } This is the class which contains webservice callout : public class ExampleHelper{ public static void makeWebserviceCallout(){ HttpRequest req = new HttpRequest(); req.setEndpoint('http://www.yahoo.com'); req.setMethod('GET'); String username = 'myname'; String password =