Rest API request timeout
We use Salesforce integration with WCF service. Currently, we are facing an issue of operation has timed out. We add chatter feed with mention using REST API and other operations doing using SOAP API. After the some requests of REST API, all operations are getting timeout. We create Salesforce connection in every time and dispose it every time in operation. We are unable to identify the issue.
If someone can help me.
You can set REST API call-out time to maximum 120 second. If your .NET application is unable to process request in 120 seconds then you will have to optimize .net webservice. Default timeout is 10 seconds.
HttpRequest req = new HttpRequest(); req.setEndpoint(endpoint_url); req.setMethod('GET'); req.setTimeout(120000);
We process 200 to 250 requests one by one at a time. Around 100 request processes successfully after that we continue getting time-out. So I think setTimeout(120000) will not work.
@Girish I will recommed to use (Asynchronous) Apex Batch to process such large number of callouts. You won't be able to do it synchronously.
@Girish: Are you trying to call a .Net REST API from Salesforce probably 200-250 in same transaction? If so, the first suggestion would be to optimize .NET api to be able to handle bulk requests for e.g. 50-100 requests in same call. It will not only help you achieve it within Salesforce, but also improve performance as there would be less network usage. It's always a best practice to bulkify web service methods.
Alternatively, there would be following approaches (not optimal)
- As mentioned by other members, use batch apex to be able to surpass governor limit of 100 API calls in a transaction
However, I would still recommend bulkifying your .Net web service to handle more requests/ records in single invocation.
Total number of callouts (HTTP requests or Web services calls) in a transaction is 100,....
So if you have to really issue 100+ request you need to go asch , also if possible bulkify your request rather than sending 250 + request. if that is possible and right for you.
Please paste your code. we can see for any other way..
Best Regards, Hari