Name | Required | Multiple Values | Description |
---|---|---|---|
GET | yes | no | The url for a GET request |
DEVICE | no | no | A generic_label device to receive the response |
Name | Required | Multiple Values | Description |
---|---|---|---|
POST | yes | no | The url for a POST request |
DATA | yes | no | A parameterstring required for a POST request |
MIMETYPE | yes | no | The mimetype required for a POST request |
DEVICE | no | no | A generic_label device to receive the response |
The http action can perform hhp(s) GET and POST requests. It can optionally be used with a generic_label device to store the response of the request.
If a device is given. the label- and color fields of the label device are respectively being used to store the received data and the corresponding code, size and mimetype.
While the http request in in progress, the color field is set to “busy”. During that time any new http request for the same device will be skipped.
When the http action completes the new response data is stored in the label field and the color is set to the code size and mimetype of the response.
Because the color first changes to “busy” and then, when the request finishes, to response code, size and mimetype, the color can be used to trigger other rules.
Typically, after a succesfull request, the label will look something like this:
"mylabel": { "protocol": [ "generic_label" ], "id": [{ "id": 1 }], "label": "hello world", "color": "code=200&size=11&mimetype=text/plain" },
The label field always contains the data received from the latest successfull request. So, suppose the next request would time out, the label will look like this:
"mylabel": { "protocol": [ "generic_label" ], "id": [{ "id": 1 }], "label": "hello world", "color": "code=408&size=0" },
The code, size and mimetype can be individually extracted using the EXTRACT function like this:
EXTRACT(mylabel.color, code) returns code EXTRACT(mylabel.color, size) returns size EXTRACT(mylabel.color, mimetype) returns mimetype (if present)
If no device is given, the result of the http request is ignored.
IF 1 == 1 THEN http GET 'http://www.somewebsite.com/' IF 1 == 1 THEN http GET 'http://www.somewebsite.com/' DEVICE mylabel IF 1 == 1 THEN http GET 'https://www.somewebsite.com/?command=show&format=xml' DEVICE mylabel IF 1 == 1 THEN http POST 'http://www.somewebsite.com/' DATA 'command=show&format=xml' MIMETYPE 'text/plain' DEVICE mylabel IF 1 == 1 THEN http GET 'http://192.168.1.1/myserver/'
If a device is given, other rules can be triggered using the change of the color field:
IF mylabel.color != busy THEN label mylabel2 TO 'The http action has finished' IF mylabel.color != busy THEN label mylabel2 TO 'The code is ' . EXTRACT(mylabel.color, code)