Topic updated on September 17, 2021

HTTP Page Listener

A HTTP Page Listener event trigger executes when a request is received for the specified URL.

It is important to note that you cannot have more than one HTTP page listener event type trigger listening on the same page (using a given Listener URL), nor can you listen to a page that is served up by existing web applications on the gateway (such as the web management interface).

To cause a trigger that uses this event to fire, you can do the following:

  • Enable the HTTP Server from the Administration > HTTP Server tab in the Workbench.
  • Make an HTTP request to the URL specified in Listener URL parameter in the trigger.

Defining a HTTP page listener event trigger

To define a HTTP page listener event trigger, follow these steps:

  1. From the Workbench left pane, expand the node where you want to define the HTTP page listener event trigger.
  2. Select the Project icon to display the Projects window, right-click a specific project tab to display its pop-up menu, and then select New.
    You also can select the New button at the bottom of the Projects window when a specific project tab has already been selected.
  3. The new Trigger window appears.
    Name the trigger. The trigger name can be up to 64 characters and include letters, numbers, and the underscore character. Spaces are allowed.
  4. From the Event tab, select the Trigger Event Type down-arrow, expand the Networking category, and then select HTTP Page Listener.

    The Event tab becomes active with parameters that accommodate the HTTP page listener event.
Parameter Description
Listener URL The URL that the calling application will request.
The default is /trigger, which means that if you request http://<ip address of your gateway>/trigger the trigger will be executed.
Note that you cannot have more than one HTTP page listener event type trigger listening on the same page.
Query String The query string fields of the URL that the calling application will request. The URL can contain a query string, such as "http://host/trigger/searchKey=1334&temperatureValue=72.3".
The example screenshot above shows how to map the individual query string variables into trigger input event variables.
Clicking the "..." button will bring up a list editor to edit this parameter.
The "&" character is reserved and is used as the string delimiter for this parameter.
Request Header The HTTP header fields of the URL that the calling application will request. The HTTP request can contain key value pairs in the HTTP header, such as "Host" and "From".
The example screenshot above shows how to map the individual request header key variables into trigger input event variables.
Clicking the "..." button will bring up a list editor to edit this parameter.
The "&" character is reserved and is used as the string delimiter for this parameter.
Response Header The HTTP header fields of the response that the trigger can supply with the response as key value pairs. The HTTP response can contain key pair values in the response header.
The example screenshot above shows how the trigger will inject a "Warning" field into the response header.
Clicking the "..." button will bring up a list editor to edit this parameter.
The "&" character is reserved and is used as the string delimiter for this parameter.

HTTP page listener event type trigger event variables

The input event variables available to a HTTP page listener event trigger are:

Event variable Data type Description
HTTP Content STRING If the incoming HTTP request is a POST, then this variable will hold the content that was POST'ed to the URL.
HTTP Content Length INT4 If the incoming HTTP request is a POST, then this variable will hold the length of the content that was submitted.
HTTP Content-Type STRING If the incoming HTTP request is a POST, then this field will contain the MIME type of the data that was submitted.
HTTP Method STRING The value of this variable will be the HTTP method that was invoked, such as: "GET", "POST", "HEAD", etc.
HTTP URL STRING The value of this variable will be the original URL that was captured by the HTTP Server.
HTTP Query String Variable(s) STRING Each query string field specified in the Query String parameter will map to a trigger input event variable. The trigger input event variable will contain a STRING value if the request contains the query string field name.
HTTP Request Header

Variable(s)

STRING Each HTTP request header field specified in the Request Header parameter will map to a trigger input event variable. The trigger input event variable will contain a STRING value if the request contains the request header field name.

The output event variables available to a HTTP page listener event trigger are:

Event variable Data type Description
HTTP Content STRING Whatever you set in this variable will be sent in the HTTP response body. The Content-Length is automatically set based on the length of the buffer that you write.
HTTP Content-Type STRING This variable should be set with the appropriate MIME type for the response data.
HTTP Status Code INT4 This variable should be set with the HTTP response code, such as: 200, 500, etc.
HTTP Response Variable(s) STRING Each HTTP response header field specified in the Response Header parameter will map to a trigger output event variable. The value will be inserted into the response header if the trigger output event variable is set.
Related Topics

HTTP Server