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
Tom SimmonsTom Simmons 

Help with Exceeded max size limit of 6000000

All, below is my code. While trying to make callout to an external API, I`m getting an error “System.CalloutException: Exceeded max size limit of 6000000”. Can someone please explain why this is happening ? I tried using cURL and POSTMAN and they are working fine however JSON response that is received with these tools is very large. Could this be the reason why I`m getting this error? Is SF not capable of handing large JSON response?       

 
HttpRequest obj = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        String reqBody = '{ "user": "test_user", "passwd": "2gbwefgnaiognawgona12" }';
        obj.setMethod('POST');
        obj.setHeader('Content-Type','application/json');
        obj.setEndPoint('https://test.samplepoint.com/api/UserSrvs.svc/Login');
        obj.setBody(reqBody);
        obj.getheader('Auth-Token');
        res = http.send(obj);
                                system.debug('Oauth Response: '+res.getbody());
                               system.debug('Header Auth-Token Response: '+res.getHeader('Auth-Token'));
        
                authtoken objAuthenticationInfo = (authtoken)JSON.deserialize(res.getbody(), authtoken.class);
                System.debug('objAuthenticationInfo: '+objAuthenticationInfo);
			
        
		  Http h1 = new Http();
        HttpRequest req1 = new HttpRequest();
        String reqBody2 = '{ "Accountype" : "workforce"}';
        req1.setHeader('Auth-Token', res.getHeader('Auth-Token'));
        req1.setHeader('Content-Type','application/json');
        req1.setMethod('POST');
         req1.setBody(reqBody2);

        req1.setEndpoint('https://test.samplepoint.com/api/accservices.svc/accountfeed');//URL will be your Salesforce REST API end point where you will do POST,PUT,DELETE orGET
        system.debug('======req1========'+req1);
        HttpResponse res1 = h1.send(req1);
        system.debug('==========res1============'+res1.getBody());

 
Dilip_VDilip_V
Tom,

Maximum size of callout request or response 12 MB

If it exceeds you will get that exception.

for more info:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

Mark it as best answer if it helps.
THanks.
Tom SimmonsTom Simmons
Thank you Thermo, is there a workaround to this issue? Is there any other way I can get data into Salesforce?
Dilip_VDilip_V
Tom,

No.It seems endpoints(In the above code) are taking too much time to load.They didn't even load in my browser.Make sure that endpoints are reachble.

Thanks.