The entry point to the Telematics Hub is a channel. The HTTP channel is an HTTP server capable of accepting special requests with messages to the Telematics Hub. Let's look at how to configure one.
Step 1. Create an HTTP channel
Navigate to the Channels section in the left-side menu
Click the “+” button in the bottom right corner
Give the protocol a meaningful name
Select HTTP protocol from the protocol_id drop-down field
Click Save
Step 2. Configure the request to your HTTP channel
HTTP request specifications
Method: POST
URI: taken from your channel’s card. Looks like gw.flespi.io:{your dedicated port}
HTTP/HTTPS: optional, may be selected in the channel configuration
Authorization: not required as you use your dedicated URI
Data: JSON array of objects. Each object represents a single message. Each message must be identified by some field that will be treated by flespi as the message origin identifier. By default, you may use the “ident” name that is native for flespi. However, in channel configuration, you may specify any custom field name.
Extra settings
- Message parameters — you can map up to 128 HTTP message parameters according to the desired custom naming scheme (learn more about applying custom parameter naming scheme here).
- JSON messages path — dot-separated path to fetch message JSON object or messages JSON array from the HTTP request body. Obviously, the request body is expected to contain the JSON object.
- Skip invalid messages — silently skip messages with invalid custom naming scheme or without ident to avoid data parsing errors.
E.g. for the configuration above, the valid curl request to send a message to flespi will look like:
curl -X POST -d '[{"vehicle_id":"1234", "timestamp":1234567890, "position.latitude":52, "position.longitude":48, "position.speed":55, "position.direction":75, "fuel.level":87}]' https://gw.flespi.io:27699
And the result will be displayed in the channel’s Logs & Messages tab:
3. Valuable notes
If you want the parameter naming of your custom messages to be in sync with parameters accepted by other channels, use standard flespi parameter naming. E.g. if you want to pass the object’s latitude and longitude and see it properly in TrackIt, use the parameter names “position.latitude” and “position.longitude”.
If you want to create device where these messages will be delivered from the channel use generic "HTTP" device type and corresponding ident in its configuration.
And alternatively if you want to send messages to any existing device that is using other protocol than "http" you may do this via POST /gw/devices/{device-id}/messages REST API call. However the amount of such REST API calls per minute is limited by your flespi plan while via the channel to generic HTTP device you can forward much more messages and their amount is limited only by maximum messages per minute limit for each particular channel.