AdvancedLesson 30 of 37
Callouts and integration patterns
Call other systems from Apex.
Store endpoints and credentials in Named Credentials, not in code.
apex
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Weather_API/forecast?city=Paris'); // Named Credential
req.setMethod('GET');
HttpResponse res = new Http().send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> body = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
}- You cannot make a callout after uncommitted DML in the same transaction; use async Apex.
- External Services generate Flow actions from OpenAPI specs; External Objects (Salesforce Connect) show outside data.
- Patterns: request-reply, fire-and-forget, batch sync, event-driven. MuleSoft or other middleware helps when many systems connect.