mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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
This commit is contained in:
committed by
Neil Lathwood
parent
445e70c52e
commit
fca10c61df
@ -44,6 +44,9 @@ class Api implements Transport
|
|||||||
curl_setopt($curl, CURLOPT_URL, ($method == "get" ? $host."?".$api : $host));
|
curl_setopt($curl, CURLOPT_URL, ($method == "get" ? $host."?".$api : $host));
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($method));
|
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);
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $api);
|
||||||
$ret = curl_exec($curl);
|
$ret = curl_exec($curl);
|
||||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
|
Reference in New Issue
Block a user