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

Callout from scheduled Apex not supported

Dear Product Manager in charge for the "Apex Scheduler",


I was wondering why my code did not worked when scheduled. After requesting the debug logs, I could see the following:



EXCEPTION_THROWN|[45,19]|System.CalloutException: Callout from scheduled Apex not supported.


Here are my questions:


1. Is this going to be officially changed?

2. Is there a workaround?

3. Did I missed something in the documentation or is it simply not written down there?


Quite disappointed,




Best Answer chosen by Admin (Salesforce Developers) 
You need to use the @future annotation. See for an example

All Answers

You need to use the @future annotation. See for an example
This was selected as the best answer

Of course! Thanks for the hint.

I had that added in my Sandbox, but not deployed yet. Don't know what happened.




Chirag MehtaChirag Mehta

Thanks for the hint, it helped!


FYI, that link is currently returning a page with the message below, I might be suffering from copy/paste failure, or maybe it's a temporary issue? 


Heroku | No such app

There is no app configured at that hostname.
Perhaps the app owner has renamed it, or you mistyped the URL.



Anyway, for future googler's the design pattern below worked for me.


There are some design decisions that you'll need to make for yourself when using this.  My test approach might not be necessary for your implementation, I included it as without it I was hitting the "System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out" error because the system.schedule() method runs "DML" on the CronTrigger table which blocks the callout.


I'm interested in more elegant solutions than the "if(! test.isRunningTes())" approach if anyone has any.



global class className implements Schedulable{
    global void execute(SchedulableContext sc){
    public static void blah(){
    public static void blah(Object fakeResponse){
        //do whatever prep is necessary
        Object response = fakeResponse;
        if(! test.isRunningTest()) response = actualCallout();

public class test_className{
    public static testMethod void test(){
            system.schedule('jobName',cron_expression, class);