Skip to content

Notifications

Paul Salmon edited this page Aug 25, 2021 · 16 revisions

Notifications allow FileWatcher to send out an API request to an endpoint once a change has occurred. All notifications for a watch are specified under the <notifications> element within the <watch> element.

Two child elements can be specified under the <notifications> element: <waittime> and <notification>.

The <waittime> element specifies the number of millseconds between sending requests. This applies to all notifications listed under the same <notifications> element. The default, and lowest amount of time, is 30000 milliseconds (30 seconds). If you specify anything lower than 30000 milliseconds, then the default of 300000 will be used. This value is used to ensure an endpoint isn't overloaded with requests if many changes are detected. All changes that will be sent to the same notification endpoint, will be queued and sent as one request to that endpoint.

The <notification> element specifies the details of the request, which are outlined in the following sections.

Notification Elements

To send a notification request to an endpoint, the following information can be specified:

Element Description
url The URL to connect to for the notification.
method The HTTP method to use for the request. Default: POST
triggers The triggers for the notification.
For more information, see Triggers.
data Data to send for the request.

URL

This is the valid URL to the endpoint and is specified using the <url> element.

Method

The <method> element specifies the HTTP method used in the request to the endpoint. The valid values are:

Method
POST
GET
PUT
DELETE

Note: The method names are case-sensitive, so they must be added to the configuration file exactly as shown in the table above.

The default value for the <method> element is POST.

Triggers

Information about the valid triggers, can be found on the Triggers page.

Data

The <data> element contains information that is sent to the endpoint. This element contains the <headers>, <body>, and <type> child elements to provide details about the data sent with the request.

Headers

The <headers> element allows you to specify various headers to include in the request. Each header is specified within a <header> child element, and contains a <name> and <value> pair of elements. For example:

<headers>
    <header>
        <name>HeaderName</name>
        <value>HeaderValue</value>
    </header>
</headers>

Body

The <body> element provides information to send in the request. You can specify any message in the <body> element, or you can use the [message] placeholder to have FileWatcher write the change message into the body.

Type

The <type> element indicates the type of request is to be sent to the endpoint. The valid values are:

Type
JSON
XML

Note: The typenames are case-sensitive, so they must be added to the configuration file exactly as shown in the table above.

The default value for the <type> element is JSON.

Examples

Send a notification (every 60 seconds) to a Gotify endpoint when a file is created or changed in C:\Temp:

<watches>
    <watch>
        <path>C:\Temp</path>
        <notifications>
            <waittime>60000</waittime>
            <notification>
                <url>http://192.0.2.100/message</url>
                <method>POST</method>
                <triggers>
                    <trigger>Change</trigger>
                    <trigger>Create</trigger>
                </triggers>
                <data>
                    <headers>
                        <header>
                            <name>X-Gotify-Key</name>
                            <value>AAA-A-AAAA-1-3A</value>
                        </header>
                    </headers>
                    <body>
                        {
                            "message": "[message]",
                            "priority": 7,
                            "title": "File Watcher"
                        }            
                    </body>
                </data>
            </notification>
        </notifications>
    </watch>
</watches>
Clone this wiki locally