HTTP request

Standard HTTP request

Allows you to send an HTTP request to the specified server. The server response is not parsed and cannot be used.

To create an HTTP request you have to specify the following parameters:

Parameter

Description

Parameter

Description

Name

The name of the element in the system

Login

Login string can be inserted as a macro $LOGIN$

Password

Password string can be inserted as a macro $PASSWORD$.

For presentation as a hash, the macros $PASSWORD_MD5$ and $PASSWORD_SHA1$ can be used.

Recipient

Recipient address string can be inserted as a macro $RECIPIENT$

Message

Message text in URL encoding, may contain the following %-macros:

%1 - logic definition
%2 - state of sensors
%3 - date and time
%4 - logic name
%5{id} - sensor name (by identifier or %8)
%6{id} - sensor state (by identifier or %8)
%7{id} - sensor value (by identifier or %8)
%8 - last modified sensor id
\n - a new line

Message text can be inserted as a macro $MESSAGE$

Request type

Type of HTTP request: GET, POST, DELETE, PUT

Server

Server string may contain $-macros

Head

Request head string may contain $-macros, for multiple head properties, use line breaks or symbol '\n'

Data

Data string may contain $-macros

The Test button allows you to send HTTP requests (the %-macro will not be filled), and make sure that everything works correctly.

After sending the request, the server response can be seen in the "Server answer" field.

HTTP/1.1 200 OK Server: nginx/1.16.1 Date: Wed, 29 Jan 2019 11:10:35 GMT Content-Type: text/xml; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Expires: -1 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache <error type="no error" />

To associate the HTTP request task with an event in the system, use logic schemes or group notifications.

Send sensor data in JSON format

Here is a simple example of how to send the sensor data (measured value, state, etc.) to a server in the format of JSON structure.

  1. Fill in the necessary fields, such as the destination server and the type of request. 

  2. Be sure to specify a line in the "Head" field indicating the type of request: Content-Type: application/json

  3. In the "Data" field, write the $MESSAGE$ macro. This will mean that a text from the "Message" field will be used as data for the request.

  4. In the "Message" field, enter the JSON structure using macros to access the sensor parameters (see above or How to use macros in the text of a notification).

  5. The data structure can be sent according to a schedule using a timer: How to use "Timer" (article link)

 

Remember that during test sending, macros are not replaced by sensors value.