Callout not allowed from this future method. Please enable callout by annotating the future method. eg: @Future(callout=true)

Callout not allowed from this future method. Please enable callout by annotating the future method. eg: @Future(callout=true)

Exception:

Callout not allowed from this future method. 

Resolution:

Please enable callout by annotating the future method with callout=true. 

Example:

@future(callout=true)

Sample Code:

 @future(callout=true)  
    public static void post(String u, String p)
    {
        try
        {
            HttpRequest req = new HttpRequest();
            ............................................................                   
            Http http = new Http();
            HTTPResponse res = http.send(req);           
            System.debug('Response is ' + res.getBody());
            ..................................................................
            ..................................................................
            ..................................................................
        }
        catch(Exception e)
        {
            ..................................................................
            ..................................................................
        }
    }

Leave a Reply