+ Start a Discussion
Nagesh ENagesh E 

Bulk Callout in salesforce

I am able to get all the Id's problem is it has more than 10 Id and I need to do a callout for each and every Id

I need to go for BulkCallout but bulk is supporting only 1 callout ,is there any way that i can do a callout outside and get all the Id's and pass those id's to Bulk class



public static void updateAccount() {
    //construct an HTTP request    HttpRequest req = new HttpRequest();    req.setEndpoint('https://api.yourmembership.com'); 


  req.setBody('<?xml version="1.0" encoding="utf-8" ?><YourMembership><Version>1.70</Version><ApiKey>XXXXXXXXXXXXXXX</ApiKey><CallID>1</CallID><SaPasscode>XXXXXXX</SaPasscode><Call Method="Sa.NonMembers.All.GetIDs"></Call></YourMembership>'); 

      Http http = new Http();    HttpResponse res = http.send(req);   

Dom.Document doc = res.getBodyDocument();   

Set<string> st = new Set<string>();   

for(dom.XmlNode node : doc.getRootElement().getChildElements()) {    if(node.getName()=='Sa.NonMembers.All.GetIDs') {  for(dom.XmlNode node2 :node.getChildElements())  {  if(node2.getName()=='NonMembers'){  for(dom.XmlNode node3 :node2.getChildElements()){    st.add(node3.getText());  }    }   }      }}


this is the other callout..

HttpRequest reqP = new HttpRequest();    reqP.setMethod('GET');    reqP.setEndpoint('https://api.yourmembership.com');   

reqP.setBody('<?xml version="1.0" encoding="utf-8" ?><YourMembership><Version>1.70</Version><ApiKey>xxxxxxx</ApiKey><CallID>'+CallId+'</CallID>


<Call Method="Sa.People.Profile.Get">



  Http httpP = new Http();   

HttpResponse resP = httpP.send(reqP);   

Dom.Document docP = resP.getBodyDocument();    


Best Answer chosen by Admin (Salesforce Developers) 

Use Batch Apex + AllowCallout and limit to 1 record per batch.