You need to sign in to do that
Don't have an account?
Tom Simmons
Help with Callout to external system
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” synchronously. I believe this is happening since payload that is being received is very large. I was wondering if there is a way to work across these limits. I tried using @future too however its giving me an error too "System.LimitException: Apex heap size too large: 12649268". Can someone please suggest a better way to get data in Salesforce?
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());
Normal heapsize is 6MB only.
you should optimize your code.
The response which you are getting from (req1.setEndpoint('https://test.samplepoint.com/api/accservices.svc/accountfeed');) is hitting the govt limit.
Optimize the code of that end point url(cls- accountfeed) and try to retrive less record in single transaction.
Regards,
GM