2

Using Batch apex i am trying to Insert new records in to custom object from json string in salesforce from API url. When my batch apex class run i got this error in apex log. please explain me

1 Answer 1

5

The Salesforce platform has a number of size limits that are enforced by the throwing of uncatchable errors. These limits are described in e.g. the Salesforce Limits Quick Reference Guide. When dealing with large volumes of data you need to consider these.

By its numerical value it looks like your are hitting the:

Maximum size of callout request or response (HTTP request or Web services call) 3 MB

A solution would be to change your API request to only retrieve a subset of the custom object JSON at once and so split the work up into multiple requests where each request involves less than 3M bytes of data.

PS To be able to do that splitting, the API that you call must have some mechanism that allows it such as supporting a date range or limit on the number of items returned. (Another way to reduce the size is to get less data returned "per row" assuming the API has that option.) If the API doesn't and can't be changed (i.e. its not under your company's control) then you face the painful task of having to build a proxy service hosted on a platform that does not impose such a limit e.g. Heroku so your Salesforce org calls that and that calls the API and holds on to the response and passes back smaller parts of it.

I don't think Salesforce support can increase this 3M limit (its not listed here List of Features and Limits which can be activated/increased by the support) but you could ask them to be sure if the data is only a few MBytes above the limit.

2
  • Keith, can you please elaborate on how we can change your API request to only retrieve a subset of the custom object JSON at once and so split the work up into multiple requests in terms of coding? Nov 1, 2014 at 14:22
  • @RohitPatil I've added a PS to the answer on this.
    – Keith C
    Nov 3, 2014 at 8:35

You must log in to answer this question.

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