Skip to main content

Callouts

Explore practical guides and implementation patterns for this topic.

Posts

Topic Apex
Apex Development

How to Fix "You Have Uncommitted Work Pending" Error in Salesforce

💬 In plain words: The error System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out occurs when your code changes the database (like using an insert or update statement) and then tries to send an HTTP callout to an external server in the exact same synchronous process. Salesforce actively blocks this to prevent database locks from hanging open while waiting for external servers to reply. When developing custom backend integrations in Salesforce, encountering the "uncommitted work pending" error is almost a rite of passage. Understanding why this strict transaction limit exists—and how to architect your Apex to respect it—is the key to building resilient, enterprise-grade system integrations.
Read article
Topic LWC
Lightning Web Components

Upload Files via Multipart/Form-Data in Salesforce Apex: HTTP Callout Guide

💬 In plain words: A multipart/form-data HTTP request is the standard way to send binary files (like PDFs or images) along with text parameters to an external server. In Salesforce, you can achieve this in two ways: via LWC directly from the browser (which is fast and avoids server limits), or via Apex (which is highly secure and perfect for system-to-system integrations). Integrating Salesforce with external document systems like AWS S3, Google Drive, or custom OCR APIs almost always requires uploading files. Standard JSON REST APIs break when handling raw binary data, so developers must use the multipart/form-data content type. However, building these requests requires specific techniques depending on whether you are working on the client-side (LWC) or the server-side (Apex).
Read article
Topic LWC
Lightning Web Components

How to Make External HTTP Callouts from Salesforce LWC

In plain words: When building modern web applications, you often need to talk to third-party services—like checking if a phone number is valid, looking up weather data, or processing payments via an external API. In Salesforce Lightning Web Components (LWC), because your code runs directly in the browser, you can use the standard JavaScript fetch() method to talk directly to external web services without needing to write backend Apex controller code! Traditionally in Salesforce, if you needed to make an HTTP request to an external server, you had to route the call through an Apex class using the Http and HttpRequest classes. While Apex callouts are still mandatory for secure server-to-server communications, Lightning Web Components run on modern browsers that natively support the standard JavaScript fetch() API. In this guide, we will walk through how to build a phone number verification component that queries an external REST API directly from your LWC contro...
Read article