Engineer Blog: (Outsystems) Calling External APIs

Let us introduce the learning topics we work on daily as part of our engineer blog. This time, it’s Team 2, focusing on low-code development!

This time’s theme: (Outsystems) Calling External APIs

In Outsystems, there are several ways to use externally published APIs. This time, we’ll focus on introducing the method for calling REST-style APIs.

The API we will use this time

This time, we’ll use an example of calling ‘Completions,’ one of the APIs provided by OpenAI (link: API reference). It’s the API that powers ‘ChatGPT,’ enabling the functionality where users send a request and the AI responds with a written answer. Many of you might have seen or used it before, haven’t you?

Implementation Example

This time, we used this API to create a feature where AI evaluates Japanese reports submitted by users and provides feedback on the content, including assessments and suggestions for improvement.

The layout of the API execution screen

The layout is quite simple: users input text into the ‘Report Input Field’ on the left side of the screen. By pressing the ‘Evaluate’ button, evaluation results and improvement feedback are displayed in the ‘Feedback’ section on the right.

Action upon pressing the button
”GetFeedback” Action

The process upon pressing the button involves re-executing the REST API set within the Data Action. The flow includes setting parameters for the request required for API execution and then executing the API itself. So, how do you configure the API request here? By providing a sample request in Outsystems, it automatically generates the necessary configuration. Below, we’ll explain further with images.

Display the REST context menu. Here, select ‘Consume REST API…
This time, select ‘Add single method.’
A screen to configure the desired REST URL and request/response samples. Here, set up the request/body based on the API Reference provided in the previously mentioned ‘Completions’ link.
Example of Body Configuration
Example of Header Configuration
Using the body and header input details, input test data and perform a test run to confirm the request and response results. If there are no issues, press the ‘Finish’ button to automatically generate the main action and the necessary data structure for the request and response.

Once this is done, you can simply configure it as you would typically build logic in Outsystems: place the created REST API as an action in the flow, set the necessary inputs, and handle the return values to complete the API call.

Execution example: Feedback is returned for the entered report.

Summary

How was it? With the URL of a publicly available API and its reference, you can call it from Outsystems just like a regular action. However, be aware that publicly available APIs might have usage fees, limitations on the number of calls, or data capacity restrictions. So, please plan your usage carefully…

Team 2 will continue to share engineer blogs using low-code tools like Outsystems in the future, so stay tuned!