⛔Stuck in the Integration Part_?
⛔Stuck in the Integration Part_?
developer
www.prominentacademy.in
Question:
Expected Logic:
Middleware handles batch data synchronization between
Salesforce and other systems.
Use Bulk API for handling large data loads efficiently.
apex
Database.insert(accounts);
Common Mistakes:
Not using Bulk API for large data loads—using standard DML can
hit governor limits.
Not setting optAllOrNone properly—can cause complete failure
instead of partial inserts.
Not implementing proper logging to track failed records.
Expected Logic:
Generate an Apex class from a WSDL file.
Call the web service using the generated class.
apex
Common Mistakes:
Not setting the correct SOAP endpoint—causing authentication
failures.
Ignoring governor limits on callouts—SOAP calls count towards
limits.
Not handling timeouts—leading to failures on slow networks.
Expected Answer:
Use HttpCalloutMock to mock API responses.
Use Test.startTest() and Test.stopTest() in test classes.
apex
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
global HttpResponse respond(HttpRequest req) {
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody('{"status":"success","data":[{"id":"1","name":"John"}]}');
res.setStatusCode(200);
return res;
}
}
@isTest
private class APITest {
@isTest
static void testAPIService() {
Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
Test.startTest();
APIService.fetchAllRecords();
Test.stopTest();
}
}
Common Mistakes:
Not using Test.setMock() → Test will call real API instead.
Forgetting Test.startTest() and Test.stopTest() → Governor
limits may be exceeded.
Not handling different HTTP response scenarios (e.g., errors,
timeouts).
Expected Answer:
Use Named Credentials for authentication.
Use Apex HTTP Callouts to trigger the Lambda function.
apex
Common Mistakes:
Not handling AWS Lambda cold starts → First request may take
longer.
Using hardcoded API keys → Always use Named Credentials.
Not handling network failures → Always add retry logic.
Expected Answer:
Use Bulk API 2.0 for large data operations.
Submit batch requests asynchronously.
apex
req.setEndpoint('https://yourInstance.salesforce.com/services/data/v58.0/jobs/in
gest');
req.setMethod('POST');
req.setHeader('Authorization', 'Bearer YOUR_ACCESS_TOKEN');
req.setHeader('Content-Type', 'application/json');
req.setBody('{"object":"Account", "operation":"insert",
"lineEnding":"LF"}');
Common Mistakes:
Expected Answer:
Use Named Credentials instead of hardcoding API keys.
Store authentication details securely.
apex
Common Mistakes: