HTTP Callout in Salesforce Spring 23 – GET

With each new release lately the Salesforce Flow team has been bringing some amazing features. I am really excited about the introduction of HTTP Callout (Beta) in Spring 23′. It really starts to open up the possibility of more resources for admins to start doing more with clicks and not code. This allows an admin directly inside of flow to make an HTTP Callout to perform a Get on an external system previously this would require either an invocable apex action or an external service be created in Salesforce.

Andy and I took sometime over the last couple of weeks to test it out and you can see our video here to see our discussion and brief demo but let’s take a deep dive walkthrough on how we configured it and the steps to take. For this testing and demonstration we found a simple api that has a free use tier that allows for a set number of callouts to validate a phone number and return validation information you can find more on Api Layer and the documentation here.

Before you can create an HTTP Callout you first need to create a what’s called a Named Credential a Named Credential is what Salesforce uses to validate you are able to use the external service you are making the call to.

1️⃣ In Setup go to Named Credentials

2️⃣ Click on External Credentials then click on New

(Yes we are doing this before creating our Named Credential because we are going to use it in our Named Credential.)

3️⃣ Enter the initial details for your External Credential

4️⃣ After hitting save scroll down on the new External Credential until you see Principals and click on New

5️⃣ Enter in your Principal details this is what the API service will use to authenticate

6️⃣ Click on New in Custom Headers and we are going to create the header to pass through our authentication

7️⃣ Create one more header to set how to accept the data from the api service

8️⃣ Go to the Named Credentials tab and click on New

9️⃣ Enter the details of your Named Credential and click save

🔟 Allow users the use the External Credential. I created a permission set to handle permissions.

1️⃣1️⃣ New Fields

I created 2 fields on the Lead Object Phone_Number_Details__c a rich text field to hold the information about the phone number that will get returned in the callout and I also created a checkbox field called Phone_Number_Validated__c that is checked true or false if a phone number has been validated in the service

1️⃣2️⃣ Let’s make a flow

In this example I am using a record-triggered flow that will fire when a lead is created. I set two conditions on Phone to make sure this fires only when there is a value in the Phone field. I also marked it to include an Asynchronous path since we can only make a callout Asynchronously.

On the asynchronous path click on the “+” and then add an action

After clicking on action a modal will pop up and you will want to scroll down to the bottom of the left panel and click on “Create HTTP Callout (Beta)”

Next fill out the details for the HTTP Callout Action you are creating the name is all one word no special characters or spaces, make sure to add a description because you will be able to reuse this in other flows without a need to create a new one so make it easier on other admins, devs and your predecessors so they know what it does, and finally choose the named credential you created in Step 1.

On the next screen we want to give it another label and description along with setting our Method which in the beta is only GET which means we can only retrieve data from an external service. Optionally, we can set a URL Path to ‘/validate’ as specified in our API documentation for the desired service action. We’ll also set Query Parameters ‘apikey’ and ‘number’, both strings as defined in the API docs, making them required to avoid call failure. The task is to give an example of what a successful json response will look like. Once again we get this from our API Documentation. After you paste your example click review and you should see the data structure on the right click done.

1️⃣3️⃣ Configure the new action you created.

Give it a name and description like all best practices. In the apikey input I am referencing the label I created in step 3 using the global variable for label. In the number field I am referencing the phone file using the Record Variable from the lead

1️⃣4️⃣ Almost done

I created a text template to populate the Phone Details Field I created. In the text template I am referencing the outputs from my service I just created. It will create what’s called an Apex Defined Variable I can reference specific pieces of data.

1️⃣5️⃣ Update the Lead

Here I am updating the Lead Record that is my Triggering Record updating the Phone Validated and Phone Detail fields.

1️⃣6️⃣ Debug, Validate, Activate, Deploy

Next up debug your flow. Make sure you set to debug on the asynchronous path and review your debug details. Validate it is doing what you expect. Once it’s validated activate your flow and deploy it 🙂

1️⃣7️⃣ Take a deep breath exhale, pat yourself on the back. Put on your superhero cape, and enjoy your drink of choice

Views and opinions in this article are my own and do not represent that of Salesforce.

Thanks for reading.

This guest post was penned by Josh Dayment.

Note: To watch the demo on Youtube, click below.

To read about the HTTP Callout POST method, click here.

HTTP Callout in Salesforce Summer 23 – POST – 1/3


Comments

13 responses to “HTTP Callout in Salesforce Spring 23 – GET”

  1. Excellent post Josh Dayment. Thank you, my friend.

  2. Hi I tried the Http callout feature. The response I got is as : 2XX (LeadPhoneValidation_Phonevalidation_OUT_2XX : { })
    responseCode (200).
    Could you please help me where the problem might have occured.

    1. Josh Dayment Avatar
      Josh Dayment

      Hi Tara a 200 response means it was successful. One thing I did notice was in order to get all of the correct information from the API service you need to include the country code for the phone number for example 1-555-555-5555 for a US Phone number if I were to enter without the country code of 1 I still get a successful response just no data is returned.

      1. And Tara, please join us here if you need further assistance. Thanks for the response, Josh.

        https://salesforcebreak.com/flow-support-slack/

  3. Hi @ JOSH DAYMENT, I used phone number with country code too but the output remains same as
    pikey = {!$Label.Phone_Validation_Key} (XXXX………..)
    Phone = {!$Record.Phone} (1-555-555-5555)
    Outputs

    2XX (LeadPhoneValidation_Phonevalidation_OUT_2XX : { })
    responseCode (200)
    and

    Update the Lead record that triggered the flow

    Conditions to update the record
    None—Always Update Record
    Update the record’s fields
    Phone_Numbe_Details__c = {!PhoneNumberDetails} (Carrier:Line Tyoe: Location: )
    Phone_Number_Validated__c = {!PhoneVerification.2XX.valid} (null)

    please help me to track the issue…I followed the blog..

  4. Harald Avatar
    Harald

    This looks great. Do you know if it is possible too, to have a flow being riggered by a webhook push?

    1. I don’t know, however, the author of this post Josh will be presenting this week on Automation hour. Watch that session and ask your question there, please.

  5. […] Create HTTP Callout – GET […]

  6. […] the HTTP Callout GET method when it came out in beta. Now this functionality is in GA. Read the blog post here and watch the YouTube recording here. It shows you how to build a flow that can check the […]

  7. […] Read the popular post: HTTP Callout in Salesforce Spring 23 – GET […]

  8. Please note that the original post has been edited by Josh Dayment. The updated instructions include named/external credentials rather than custom label.

Leave a Reply

Discover more from Salesforce Break

Subscribe now to keep reading and get access to the full archive.

Continue reading