ThingsBoard Professional Edition with White-labeling and Platform Integrations Learn More

REST API Call Plugin

Overview

Rest API plugin is responsible for sending HTTP requests to specific endpoints triggered by specific rules

Configuration

You can specify following configuration parameters:

Server-side API

This plugin does not provide any server-side API.

Example

In this example, we are going to demonstrate how you can configure Rest API Call extension to be able to send POST or PUT request to particular REST endpoint every time new telemetry message for the device arrives.

Prerequisites before continuing REST API Call extension configuration:

REST API Call Plugin Configuration

Let’s configure REST API Call plugin first. Go to Plugins menu, click on a ‘+’ button and create new plugin:

image

image

Please set URL, port, path and authentication method correctly for the REST endpoint where the request is going to be transferred.

Save plugin and click on ‘Activate’ plugin button:

image

REST API Call Rule Configuration

Now it’s time to create appropriate Rule.

image

Add filter for POST_TELEMETRY message type:

image

Click ‘Add’ button to add the filter.

Then select ‘REST API Call Plugin’ in the drop-down box for the Plugin field:

image

Add an action that will send temperature telemetry of the device to the particular REST action-path. In the action you can provide request type and result code that you expected from the REST endpoint in case of a successful call.

image

image

Click ‘Add’ button and then activate Rule.

Sending Temperature Telemetry

Now for any of your devices send Telemetry message that contains ‘temp’ telemetry:

{"temp":73.4}

You should see ‘73.4’ as a body request in appropriate rest endpoint once you’ll post this message.

Here is an example of a command that publish single telemetry message to locally installed ThingsBoard:

mosquitto_pub -d -h "localhost" -p 1883 -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -m '{"temp":73.4}'