Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I want to call out my web service after the insert process of a custom object with a delay of 2 minutes. But i am getting that exception FATAL_ERROR|System.CalloutException: Read timed out How can i fix that problem ? Here is my implementation.

Callout class:

public class HttpCallout{
    @Future(callout=true)
    public static void getContent(String url){
        Http h = new Http();

        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        req.setTimeout(2000);

        HttpResponse res = h.send(req);
        String response = EncodingUtil.urlDecode(res.getBody(),'UTF-8');
        System.debug('***response****'+response);
    }

    public void serviceCaller(){
        getContent(url);
    }
}

Trigger:

trigger AfterInsertOrUpdate on Sales_Order__c (after insert) {
    System.debug('Making future call to update account');
    HttpCallout httpCallout = new HttpCallout();
    httpCallout.serviceCaller();
    System.debug('After Insert');
}

Any help would be appriciated.

share|improve this question

1 Answer 1

The argument to HttpRequest.setTimout is a millisecond value so for 2 minutes:

req.setTimeout(2 * 60 * 1000);

PS With the clarification that the desire is to make the web service call after a 2 minute delay I suggest you experiment with this Need System.schedule cron string for run once approach. In your case you would build the cron string to be 2 minutes from the current date/time.

share|improve this answer
    
I tried that but the web service has been called out just after the insert process. –  user3864408 Aug 8 at 13:09
    
@user3864408 Perhaps a better title for your question would be "How to schedule a web service call for 2 minutes in the future". –  Keith C Aug 8 at 13:11
    
Yes it is then how can i make it ? –  user3864408 Aug 8 at 13:19
    
@user3864408 See link in PS. –  Keith C Aug 8 at 13:21
    
i didnt understand anything from the link i think this is not what i am looking for –  user3864408 Aug 8 at 13:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.