elasticio / rest-api-component-v2

The REST API v2 component is a simple yet powerful component that allows you to connect to any REST API without programming your own components and deploying them into the platform.
Apache License 2.0
1 stars 5 forks source link

REST API v2 Component

Table of Contents

Description

The REST API v2 Component is designed to interact with the most common APIs that are based on the HTTP protocol.

Credentials

The component supports several authentication types. Depending on the selected type, different credential fields will be required.

No Auth

This option does not require any specific fields and is used for APIs that do not require authentication or if you need to implement a custom mechanism, such as using the request body.

Basic Auth

This is one of the simplest techniques for enforcing access controls to web resources. It uses two fields:

Each request will include an additional header field in the form of Authorization: Basic <credentials>, where <credentials> is the Base64 encoding of Username and Password joined by a single colon :.

API Key Auth

An API key is a secret unique identifier used to authenticate and authorize access to an API. It requires two fields:

Each request will include an additional header field formatted as <Header Name>: <Header Value>.

OAuth2

OAuth2 is an authorization flow that allows third-party applications, such as this component, to access a user’s resources without sharing their credentials. It uses tokens to grant limited access to services, enabling secure delegated access across different platforms.

Before creating this type of credentials, you typically need to establish an integration in the external system—this could be a client/application or something similar. Often, you will also need to provide a redirect URI for this platform, which will look like https://{your-tenant-address}/callback/oauth2.

After that, you will need to fill in the following fields in the component:

After filling in all required information, press the Authenticate button. A new window for the third-party system should open, where you need to log in and grant access.

If everything is successful, the component will automatically collect and refresh the access token, which will be added to the headers of each request in the form of Authorization: Bearer <access token>.

Actions

HTTP Request (Axios Library)

Configuration Fields

Input Metadata

None

Output Metadata

If Download as Attachment is checked:

Triggers

HTTP Request (Axios Library)

Refer to the actions section HTTP Request (Axios Library).

Examples of Usage

Uploading Files

To upload a file, ensure that you check the Upload File option in the configuration. You will then have the following options:

Upload Using application/octet-stream

image

  1. Add the URL to which you will upload the file.
  2. Set the Body content type to application/octet-stream.
  3. In the body, provide the URL to the data source from which you need to retrieve the file.

Upload Using multipart/form-data

image

  1. Add the URL to which you will upload the file.
  2. Set the Body content type to multipart/form-data.
  3. Press the Add Part button.
  4. Enter a key that describes the field containing the data; a common name is file.
  5. Switch to JSONata mode.
  6. Create an object with the key url—this will be the data source from which you need to retrieve the file.

Sending XML or Text Data

image

  1. In Integrator mode, you can simply place your text or XML inside the body.
  2. Mapping from previous steps is also available.

You can switch to JSONata mode if you need to utilize JSONata expressions.

Sending JSON Data

image

  1. In JSONata mode, you can simply place your JSON inside the body.
  2. Mapping from previous steps and any JSONata expressions are also available.