The advent of HTTP Callouts in Salesforce Flow has opened new avenues for seamless integration with external services. This feature allows for direct calls to web services without the need for Apex classes.
In this blog, you will:
- Learn what HTTP callouts are and how they fit into Salesforce’s architecture.
- Get to know the essential elements like Named Credentials, External Credentials, and Permission Sets that make HTTP callouts secure and efficient.
- Understand the different HTTP methods like GET, POST, PUT, PATCH, and DELETE and how they can be used in callouts.
- A step-by-step walkthrough for implementing an HTTP callout in Salesforce, from initial setup to testing.
By the end of this blog, you should be well-equipped to implement, manage, and optimize HTTP callouts in Salesforce Flow, thereby enhancing your Salesforce integrations.
HTTP Callouts
An HTTP callout refers to the process of making a network request from one system to another over HTTP or HTTPS protocol. In the context of Salesforce, it involves Salesforce sending a request to an external service and receiving a response back, allowing for data exchange or triggering specific actions on the external system.
HTTP Callouts Using Salesforce Flow
The new HTTP Callout feature in its Beta stage enables Salesforce Flows to directly communicate with external web services, bypassing the previous requirement for Apex classes. Currently limited to GET requests, this feature is particularly valuable for administrators, as it allows for direct API interactions within any Flow that includes an action element.
Key Components for HTTP Callouts
- Named Credentials: Securely store the URL and authentication details for the callout.
- External Credentials: Store authentication details for external services.
- Permission Sets: Define the permissions needed to execute the callout.
HTTP Methods
- GET: Used for retrieving data from an external service.
- POST: Utilized for transmitting new data records to an external service for processing or storage.
- PUT: Updates existing data in an external service.
- PATCH: Partially updates existing data in an external service.
- DELETE: Removes data from an external service.
Implementing an HTTP Callout in Salesforce
1. Creating a Permission Set
- Navigate to the Salesforce Setup area.
- In the Quick Find search field, enter “Permission Sets.”
- Click on “Permission Sets” and then “New.”
- Name the Permission Set (e.g., “HTTP_Callout_Permission”).
- Assign the “API Enabled” permission to this set.
- Save the Permission Set.
- Allocate this Permission Set to individuals responsible for initiating or overseeing HTTP callouts.
2. Setting Up External Credentials
- Go to Salesforce Setup.
- In the Quick Find search field, enter “Named Credentials.”
- Click on “Named Credentials” and then “New External Credential.”
- Fill in the required fields, such as the API key or username/password for the external service.
- Save the External Credential.
3. Creating Named Credentials
- Still in Salesforce Setup, locate “Named Credentials” via the Quick Find box.
- Click “New Named Credential.”
- Fill in the required fields: Label and Name: A descriptive label and name for the credential.
- Identity Type: Named Principal or Per User, depending on the use-case.
- Authentication Protocol: Choose the appropriate protocol (e.g., Password Authentication, OAuth 2.0).
- For Password Authentication, provide the corresponding username and password credentials.
- Save the Named Credential.
4. Mapping External Credential Principle and Permission Set
- Navigate back to the Permission Set created earlier.
- Click on “Edit Assignments” under “External Credential Principle Access.”
- Select the External Credential Principle that corresponds to the Named Credential.
- Save the changes.
5. Creating the Salesforce Flow
- Open Salesforce Flow Builder.
- Initiate a new Flow or access an existing one
- Incorporate the “Action” element by dragging it onto the workspace canvas.
- In the “Action” properties, search for “Create HTTP Callout” and select it.
Configure the action:
- Method: Choose the HTTP method (GET, POST, etc.).
- Endpoint: Use the Named Credential created earlier.
- Headers: Add any required HTTP headers.Body: If using POST or PUT, add the request body.
- Connect this action element to the remaining components within your Flow.
- Finalize by saving and enabling the Flow for use.
- Test the Flow to ensure the HTTP callout is working as expected, either by running the Flow manually or triggering it via its configured conditions.
Conclusion
The integration of HTTP Callouts in Salesforce Flow has revolutionized the way Salesforce interacts with external services. By eliminating the need for Apex classes, this feature has simplified the process, making it more accessible, especially for admins. The key components—Named Credentials, External Credentials, and Permission Sets—ensure that these callouts are both secure and efficient. While the feature currently supports only GET calls, its potential impact is significant, offering a range of possibilities from data synchronization to real-time updates.
Ready to dive deeper into Salesforce and connect with like-minded professionals? Join our community on Slack.
For those looking to elevate their skills further, don’t miss out on our online Salesforce bootcamps. Experience hands-on training, work on real projects, and become a Salesforce pro. Join us now!