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
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

 

@Future(callout=true) 

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

  req.setMethod('GET'); 

  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>

<SaPasscode>xxxxxx</SaPasscode>

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

<ID>'+listStrings[i]+'</ID>

</Call></YourMembership>'); 

  Http httpP = new Http();   

HttpResponse resP = httpP.send(reqP);   

Dom.Document docP = resP.getBodyDocument();    

 

Best Answer chosen by Admin (Salesforce Developers) 
iBr0theriBr0ther

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