Http/Rest API Callout via Salesforce Flow


Empower your Salesforce Flows with real-time data! Learn to perform HTTP callouts for dynamic external service integration

Rest API Callout via Flow

Introduction :

In the ever-evolving landscape of Salesforce automation, the ability to integrate external systems and fetch real-time data is crucial. Salesforce Flows, a powerful tool for declarative automation, can be taken to the next level by incorporating HTTP callouts. This blog post explores the concept of HTTP callouts via Salesforce Flows, providing insights into their significance and a step-by-step guide on how to implement them.

HTTP Callout :

HTTP callouts enable Salesforce Flows to make requests to external web services, fetch data, and incorporate that information into your Salesforce environment without using a code. You can set up direct integrations as needed without having to work with a developer or call a middleware tool. After you configure the HTTP callout action in a flow, Flow Builder auto-generates an external service registration, an invocable action, and Apex classes that you can use to create an Apex-defined resource for flows. You can then use the data output of the API request as input within Flow Builder and across Salesforce.

Key Benefits of HTTP Callouts in Flows :

  • Real-time Data Integration : HTTP callouts enable real-time communication with external systems. Few use cases :
    • Get Address Information using Map API
    • Get Weather Information using Weather API
    • Get payment authorization information with a payment processing API
  • Automation without Code : Salesforce Flows are designed to empower business users to automate complex processes without the need for extensive coding. With HTTP callouts, you can seamlessly integrate external data into your Flows, unlocking new possibilities for automation and reducing the reliance on custom Apex code.
  • Dynamic Decision-Making : HTTP callouts enable you to make decisions in your Flows based on real-time information from external sources. For example, you can use data from an e-commerce API to dynamically adjust pricing or inventory levels within your Salesforce processes.

Implementing HTTP Callouts in Flows – A Step-by-Step Guide :

we’ll delve into the steps of implementing HTTP callouts in a Flow with a hands-on demo. The scenario we’ll explore involves calling an external service for GB postcode lookup (https://postcoder.com/), where the Flow takes a GB postcode as input and retrieves a list of addresses associated with that postcode using the GET method.

Request Method – GET

Request URL – https://ws.postcoder.com/pcw/{apikey}/address/{countrycode}/{searchterm}

  • Create an External Credential : Create the external credential from the Named Credential Setup page, on the External Credential tab. Fill out appropriate details based on the API’s requirement.
  • Create an External Credential Principle : Create External Credential Principle for the External Credential which is created in above step.
  • Create a Named Credential : Defines the name and URL of the endpoint. The named credential is associated with the HTTP callout action when you create the action in Flow Builder.
  • Create Salesforce Flow using Create Http Callout Action :
    • Create a Screen Flow and add screen flow element to input Postcode.
  • Create Assignment Element for creating variables and assigning values to them. These variables will be used in HTTP Callout Action.
  • Create Http Callout Action by clicking on Create HTTP Callout Button.
  • Configure New Http Callout Action
    • Select Named Credentials and then click on Next Button.
  • Select Method as GET from GET, POST, PUT, PATCH, DELETE
  • Set URL Path /pcw/{apikey}/address/{countrycode}/{searchterm}. To add URL path variables, place them in curly brackets. For example: /{city}. When you invoke this action in a flow, set input values for each path variable defined here.
  • Assign the path variables which are created in previous step.
  • Set Query Parameter Keys. Use query parameter keys to create more specific requests. Keys become input parameters when you invoke the callout action.
  • Provide Sample Response by clicking on New Button.
  • After providing sample response, click on Review Button to review the Data Structure and then click on Done Button. Behind the scene it creates External Service
  • Create a screen element to display results of address which are get by external system callout in picklist field.
  • Complete Flow will look like as below image
  • Test the Flow :

References :

Read More :

Send Outbound Message via Flow in Salesforce