From fca10c61dff8f0e012455bff9966dd06cc07a145 Mon Sep 17 00:00:00 2001 From: Nash Kaminski Date: Thu, 22 Feb 2018 06:22:42 -0600 Subject: [PATCH] alerts: Set Content-type header in the API transport if the text to be sent is valid JSON (#8282) * Set Content-type header to application/json in the API transport if the text to be sent is valid JSON. * Update Api.php * Update Api.php --- LibreNMS/Alert/Transport/Api.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LibreNMS/Alert/Transport/Api.php b/LibreNMS/Alert/Transport/Api.php index 0a1b0bde32..b138a3f911 100644 --- a/LibreNMS/Alert/Transport/Api.php +++ b/LibreNMS/Alert/Transport/Api.php @@ -44,6 +44,9 @@ class Api implements Transport curl_setopt($curl, CURLOPT_URL, ($method == "get" ? $host."?".$api : $host)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($method)); + if (json_decode($api) !== null) { + curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json")); + } curl_setopt($curl, CURLOPT_POSTFIELDS, $api); $ret = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);