Salesforce flow is a powerful tool that allows you to automate business processes without writing code. One of the features that flow offers is the ability to make HTTP callouts to external systems and services. In this blog post, we will learn how to use the Create HTTP Callout action in flow builder to make GET request.
GET and POST are two common methods of sending and receiving data over HTTP. A GET request is used to retrieve data from a server, while a POST request is used to send data to a server. For example, you can use a GET request to fetch weather information from an API, or use a POST request to submit a form data to a web service.
To make an HTTP callout from flow, you need to follow these steps:
- Create an HTTP callout action in flow builder. You can find this action under the Integration category in the toolbox. Drag and drop it onto the canvas and give it a name.
- Configure the HTTP callout action by specifying the following parameters:
- Method: Choose either GET or POST depending on your use case.
- URL: Enter the URL of the endpoint that you want to call. You can use variables or expressions to dynamically construct the URL.
- Headers: Optionally, add any headers that you need to send with your request. Headers are key-value pairs that provide additional information about your request, such as content type, authorization, etc.
- Body: Optionally, add a body for your request. The body is the data that you want to send with your request, such as JSON, XML, form data, etc. You can use variables or expressions to dynamically construct the body.
- Output values: Optionally, define any output values that you want to store from the response of your callout. Output values are variables that you can use later in your flow. You can choose from these options:
- Status code: The status code of the response, such as 200, 404, 500, etc.
- Status message: The status message of the response, such as OK, Not Found, Internal Server Error, etc.
- Body: The body of the response, which is the data that the server sends back with its response, such as JSON, XML, HTML, etc.
- Headers: The headers of the response, which are key-value pairs that provide additional information about the response, such as content type, date, etc.
- Connect the HTTP callout action to other elements in your flow as needed. You can use decision elements to branch your flow based on the output values of your callout action, or use assignment elements to assign values from your callout action to other variables in your flow.
- Save and activate your flow.
To illustrate how this works, let’s look at example of making HTTP GET callout:
GET REQUEST EXAMPLE:
- Create a Named Credential with API URL : https://official-joke-api.appspot.com/random_joke
- For GET, we will use a joke API that returns a random joke in JSON format.
- Create an HTTP callout action and name it Get Joke.
- Set the Method parameter to GET and enter this URL: https://official-joke-api.appspot.com/random_joke
- Leave the Headers and Body parameters blank as we don’t need them for this callout.
- Define two output values: one for storing the status code and one for storing the body of the response. Name them Status Code and Joke Response respectively.
- Connect the Get Joke action to a screen element that displays the joke from the response body. You can use dot notation to access the properties of the JSON object in the body. For example, Joke Response.setup will return the setup part of the joke and Joke Response.punchline will return the punchline part of the joke.
That’s it! You have successfully learned how to make HTTP GET callout in salesforce flow. You can use this technique to integrate with various external systems and services that expose APIs over HTTP.
Leave a comment