Salesforce limits: "Maximum size of callout request or response: 3MB", is there a way to "trap this exception", to gracefully handle responses that end up being over 3mb? I'm hitting these limits and it's resulting in an uncaught exception even in a try/catch block

Gov. Limits: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

Http Classes (where I've been looking for a method): http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http.htm

  • This is now 6/12 MB. Anyway to overcome 12 MB limit?? :) As Maximum size of callout request or response (HTTP request or Web services call) is 6 MB for synchronous Apex or 12 MB for asynchronous Apex, so at max 12 MB attachment can only be sent to Amazon S3 using HTTP request. Aug 12, 2016 at 12:42

1 Answer 1


This isn't unique to this limit. System.LimitException is uncatchable and means that your script will be killed, even if it happens inside a try/catch block.

I don't know of any good way to handle this for responses within the same context. However, if you make the callout in a different context (JS remoting, etc.) and add some sort of success/error logging you can check your logs from the main context to see if the callout completed successfully.

If you want to check the size of your request prior to sending it out the best way is to run Limits.getHeapsize() prior to and after building the request and compare the two values.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .