+ Start a Discussion
Scott0987Scott0987 

make httprequest in batch apex

I am pretty new to apex and have never used batch apex.  I have read about it but don't quite understand it.  I have the need to write some code that will make http call outs.  My problem is that I am not sure of the exact number of call outs and I believe the govenor limit is 10.  My code for 1 call out looks like this:

global void runCallOuts{
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http........endpointhere);
    req.setMethod('GET');
    Http http = new Http();
    HTTPResponse res = http.send(req);
    JSONParser parser = JSON.createParser(res.getBody());
    while (parser.nextToken() != null) {
        if ((parser.getCurrentToken() == JSONToken.FIELD_NAME)){
            String fieldName = parser.getText();
            parser.nextToken();
            if(fieldname == 'id') {
                IDset.add(parser.getText());
            }
        }
    }
}

 What I need to do is be able to run that piece of code for each of a specific sObject that meets the requirements.  I then want to set that to run every day at 5pm or some other specific time.  Thanks for the help.  

AmitSahuAmitSahu
What is actual requirement for many call outs ? Just wanted to know if you really don't have any other option ...!!
Scott0987Scott0987

I don't have an actual number of callouts.  It could be as many as 1000