Alert Transport: API to IFTTT Maker Service (Webhook Trigger) uses wrong content-type

  • Steps to reproduce an issue.
  • The output of ./validate.php

I have trouble using API Headers provided with the Alert Transport API Template to successfully override the content type text/plain in the API POST request from LibreNMS to IFTTT Maker Service.

Using Curl and manually providing the POST request to IFTTT Maker Service.

When I have the LibreNMS Alert trigger for the transport I have created. It seems it uses Content-Type: text/plain, instead of overriding the Content-Type with the Content-Type: application/json I have set under API Headers.

Uses IFTTT Webhooks's triggers, queries, and actions → Details → Triggers → Receive a web request

 # sudo --user=librenms git -C /opt/librenms diff  
diff --git a/LibreNMS/Alert/Transport/Api.php b/LibreNMS/Alert/Transport/Api.php
index 44060310b..e08ccedee 100644
--- a/LibreNMS/Alert/Transport/Api.php
+++ b/LibreNMS/Alert/Transport/Api.php
@@ -50,7 +50,7 @@ class Api extends Transport
 
         if ($method !== 'get') {
             $request_body = SimpleTemplate::parse($this->config['api-body'], $alert_data);
-            $client->withBody($request_body, 'text/plain'); // Content-Type can be overriden by user headers
+            $client->withBody($request_body, 'application/json'); // Content-Type can be overriden by user headers
         }
 
         if ($username) {
 # sudo --user=librenms /opt/librenms/validate.php
===========================================
Component | Version
--------- | -------
LibreNMS  | 23.6.0-13-g2fb73e5f1 (2023-06-27T21:22:40+00:00)
DB Schema | 2023_04_27_164904_update_slas_opstatus_tinyint (252)
PHP       | 8.2.7
Python    | 3.9.2
Database  | MariaDB 10.5.19-MariaDB-0+deb11u2
RRDTool   | 1.7.2
SNMP      | 5.9
===========================================

[OK]    Composer Version: 2.5.8
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database Schema is current
[OK]    SQL Server meets minimum requirements
[OK]    lower_case_table_names is enabled
[OK]    MySQL engine is optimal
[OK]    Database and column collations are correct
[OK]    Database schema correct
[OK]    MySQl and PHP time match
[OK]    Active pollers found
[OK]    Dispatcher Service not detected
[OK]    Locks are functional
[OK]    Python poller wrapper is polling
[OK]    Redis is unavailable
[OK]    rrd_dir is writable
[OK]    rrdtool version ok
[WARN]  Your local git contains modified files, this could prevent automatic updates.
        [FIX]: 
        You can fix this with ./scripts/github-remove
        Modified Files:
         LibreNMS/Alert/Transport/Api.php
[FAIL]  We have found some files that are owned by a different user than 'librenms', this will stop you updating automatically and / or rrd files being updated causing graphs to fail.
        [FIX]: 
        sudo chown -R librenms:librenms /opt/librenms
        sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
        sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
        Files:
         /opt/librenms/.git/index
 # sudo --user=librenms git -C /opt/librenms reset --hard origin/master
HEAD is now at 2fb73e5f1 Add parenthesis Regex (#15124)
 # sudo --user=librenms /opt/librenms/validate.php                     
===========================================
Component | Version
--------- | -------
LibreNMS  | 23.6.0-13-g2fb73e5f1 (2023-06-27T21:22:40+00:00)
DB Schema | 2023_04_27_164904_update_slas_opstatus_tinyint (252)
PHP       | 8.2.7
Python    | 3.9.2
Database  | MariaDB 10.5.19-MariaDB-0+deb11u2
RRDTool   | 1.7.2
SNMP      | 5.9
===========================================

[OK]    Composer Version: 2.5.8
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database Schema is current
[OK]    SQL Server meets minimum requirements
[OK]    lower_case_table_names is enabled
[OK]    MySQL engine is optimal
[OK]    Database and column collations are correct
[OK]    Database schema correct
[OK]    MySQl and PHP time match
[OK]    Active pollers found
[OK]    Dispatcher Service not detected
[OK]    Locks are functional
[OK]    Python poller wrapper is polling
[OK]    Redis is unavailable
[OK]    rrd_dir is writable
[OK]    rrdtool version ok

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.