I am receiving the following error 'Web service callout failed: WebService returned a SOAP Fault: System.CalloutException: Callout loop not allowed'. My code is as follows:

pageReference pdf = Page.viewPDF;
Attachment attach = new Attachment();
Blob body;
body = pdf.getContent();

And this code is inside a loop. I thought that only soql and dml isn't allow in loop, but now this weird error. How can i solve this ?


Unfortunately there is no solution yet. As of Summer 15, Salesforce have implemented a critical update PageReference getContent() and getContentAsPDF() Methods Treated as Callouts". If enabled, the following error will be raised: "(304497466)|FATAL_ERROR|System.CalloutException: Callout loop not allowed"

A temporary workaround might be to deactivate the Critical Update.

Setup > Build > Critical Updates

A similar question was raised on Salesforce Discussion Forum.

| improve this answer | |
  • For the time being, i think that disabling the critical updates is sufficient for me. Thanks – vanessen Sep 2 '15 at 12:09

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