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

Exception while calling getContent()



 I am trying to get the content from a VF page and store it as an attachment. So i am doing below:


PageReference pg = new PageReference('/apex/myDoc?oppId=' + oppId);



Attachment att = new Attachment();

att.Body = pg.getContent(); <--- Here i get Connection reset but it is intermittent and not reproducible.


Any idea why is this happening?


Thanks for the help!!



Dirk GronertDirk Gronert

Can you pls provide more information, like where are you sung this code?




 This is used for dynamically generating a PDF document from the values on the opportunity object and also saving the same PDF as an attachment to the opportunity record.



Dirk GronertDirk Gronert

In a controller?!


Yeah thats right.