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
nayana pawar 3nayana pawar 3 

“Read Timed Out” Error : Batch Processing

I am trying to add records from API URL using batch apex in salesforce.I got an error while running batch apex. Please help me to solve this error.
Martijn SchwarzerMartijn Schwarzer
Hi nayana,

You can set the timeout on your HttpRequest or Web Service callouts to a larger value.
 
HttpRequest req = new HttpRequest();
//set timeout to 1 minute
req.setTimeout(60000);

If it's the API that returns the timeout, then there is not much more to do than error handling unfortunately.

Hope this helps!

Best regards,
Martijn Schwärzer
nayana pawar 3nayana pawar 3
Hi 
MartijnSchwarzer,

I tried this but i got this error again "Exceeded max size limit of 3000000".
Please help me as soon as possible.
Martijn SchwarzerMartijn Schwarzer
Hi Nayana,

In Salesforce, the total size of all your request and response messages combined, can be no more than 3000000 per transaction.

The error you receive, is because the response message from your http callout is too big, e.g. too much data is returned.

Maybe you can adjust the query you perform on the external system, to reduce the size of the response message?

Best regards,
Martijn Schwärzer

 
nayana pawar 3nayana pawar 3
Yes I can understand now. But i didn't got  now what can I do to solve this?
Martijn SchwarzerMartijn Schwarzer
Hi Nayana,

You've indicated that you are trying to add records from an API Url.
The number of records returned from the callout is too big, so you should try to reduce the number of returned records.

How you can do that is totally dependent on the API you are calling and the possibilities of that API.

I'm willing to dive deeper into this issue, but then I need to know which API you are calling to see if we can do anything to reduce the number of records returned by the API.

Best regards,
Martijn Schwärzer
 
nayana pawar 3nayana pawar 3
API URL : http://iprocureafrica.co/index.php/restApi/saleitems_c/3