1

I want to consume web service response from external system which is sending a very Big Response. It is breaking on simple call like :

  Http h = new Http();
  h.send(request);

I did not even started desearlize my response or starts reading the reponse and it broke

I just created by DTO and send the request.

My DTO has only following fields to send.

public class DTO {
        public List<String> name {get; set;}
        public List<String> id {get; set;}
        public List<String> crdNumber1 {get; set;}
        public List<String> employeename {get; set;}
        public boolean takeAll {get; set;} 
    }  
David Mycka
  • 1,307
  • 3
  • 26
  • 53
  • To be clear, it fails at h.send(request), or afterwards? – sfdcfox Nov 02 '17 at 04:30
  • @sfdcfox, Thanks for reply. It is failing at h.send( request)..I Print Limit.getHeapsize() before this line, its showed 1632. I also put same after that line, it didnt even reach there. – David Mycka Nov 02 '17 at 04:58

1 Answers1

3

6 MB is the limit per transaction for callouts made during synchronous execution. If you can move to asynchronous callouts via future, batchable, or queueable, you will be allowed 12 MB instead. If that won't work, you'll need to move to the AJAX Proxy, which has unlimited payload size, but must be called from JavaScript/Visualforce.

sfdcfox
  • 489,769
  • 21
  • 458
  • 806
  • Thanks sfdcfox. It means we dont have any way where we can consume more then 12 MB response in salesforce by standard web service implementation. – David Mycka Nov 02 '17 at 14:04
  • @DavidMycka Not within Apex Code. You would need to use the AJAX Proxy if you need to do so. – sfdcfox Nov 02 '17 at 14:49
  • thanks . Could you please guide me how can i call JavaScript or VF page from my ApexClass. As Webservice call starts when in ApexClass certains conditions are met. To make this Ajax call from ApexClass what should be my next steps. Thanks – David Mycka Nov 02 '17 at 20:10
  • @DavidMycka You can't call JS or VF from Apex in a way that would allow you to bypass the limit. You would need to call JS from the browser. Depending on the context, this may or may not be easy to do. – sfdcfox Nov 02 '17 at 20:44
  • @sfdcfox, is this the heap size limit you are talking about?. If yes so the apex code holds the data in memory till it sends the data to the external system? – RedDevil Nov 12 '17 at 06:08
  • @RedDevil no, I'm referring to the http call out limits. They happen to be the same size as the heap limits. You're allowed to retrieve 6 mb worth of data from an external system per transaction in synchronous code, twice that for asynchronous code. – sfdcfox Nov 12 '17 at 09:50
  • @sfdcfox, thanks is this http limit or salesforce callout http limit? Is there a documentation link you can point me to? – RedDevil Nov 12 '17 at 10:11
  • @sfdcfox, i got my answer its in the limits documentation under static apex Limits section. – RedDevil Nov 12 '17 at 18:38