How to access headers and data sent via webhook call
You can also post large data via webhook to Built.io Flow. This data can be then used in your workflow. Let’s look at an example to understand how to do it.
Let’s say you wish to retrieve the employee details posted on your REST API client (in this case, Postman) and send these details to admin via Gmail. To achieve this, follow the steps given below:
Step 1: Create the workflow
Drag ‘Webhook’ trigger and ‘Gmail - Send an Email’ action to the canvas and connect them as shown below:
Configure the ‘Gmail - Send an Email’ action as given below:
To: Enter the email ID of the recipient to whom you wish to send the webhook data.
Body: Since we want headers and webhook data to be separated, first add ‘headers’ key and then on a new line, add ‘body’ key listed under ‘Webhook’ on the right hand side of the configuration window.
You can also add ‘Query’ and ‘Method’ keys to retrieve their values.
Once you have entered these details, click on ‘Next’, test the workflow and click on 'Done'.
Step 2: Send Data via REST API Client
For this example, we will be using ‘Postman’ to post data to the specified webhook. To achieve this, configure it as given below:
HTTP Request: Select HTTP Request as ‘POST’, and enter the Webhook URL of the workflow to which you wish to post data.
Authorization: Under the ‘Authorization’ tab, select the type of authorization you had selected to secure the webhook along with its credentials. In case you have not used any authorization method, select ‘No Auth’.
Headers: Under the ‘Headers’ tab, enter ‘Content-Type’ in the ‘Key’ field and ‘application/json’ in the ‘Value’ field.
Body: Under the ‘Body’ tab, select ‘Raw’ method and enter the JSON data that you wish to post to the webhook, in the textbox that appears.
Once you have entered the data, click on ‘Send’ button.
This will trigger the workflow and post the specified JSON data to the webhook URL, which will in turn send the headers and data to the specified recipient via Gmail.