How to return an API response from a destination

If you require to use an API that requires you to send a body and get a response back, please follow the instructions below:

Illustrated in the image below is an example of a flow that prepares a JSON body to send to an API and get the response back from the endpoint then writes the Data into a buffer

The flow takes a food category in the form of a body request and then passes it to an API which returns a list of meal options, including the protein and fat of the meal.

Add a source step, In this example, a Start Flow source step is used, A Record Generator can also be used

image

Add a Calculator step, In this calculator we will prepare the body response to send to the API

In the HTTP Service destination step, Specify the URL, select any connections if required, and any other configuration required by the API
Note: Response Encoding is used to encode the response from the API, When working with files Response Encoding can be set to Binary

After the HTTP Service destination step, Add a Calculator and change input.record to input.result as per the image below
result: Dynamic: Returns result of a Destination Step

When testing a Destination, Uncheck the Disable Destination Steps options to show the response from the HTTP Service in Synatic Stop Debug Window

When the flow is executed the buffer will be populated as per the image below