From 71cd81269aa077b75d321b2c8c2312a3abdee340 Mon Sep 17 00:00:00 2001 From: mzacchi <55476929+mzacchi@users.noreply.github.com> Date: Sat, 28 Aug 2021 23:19:06 +0200 Subject: [PATCH] Update Api.php to include Options variable in the Body for POST requests (#13167) * Update Api.php * Update Api.php Correct syntax for variable replacement : '{{ $' . $metric . ' }}' * style Co-authored-by: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com> --- LibreNMS/Alert/Transport/Api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LibreNMS/Alert/Transport/Api.php b/LibreNMS/Alert/Transport/Api.php index 178c95741e..5f1f100344 100644 --- a/LibreNMS/Alert/Transport/Api.php +++ b/LibreNMS/Alert/Transport/Api.php @@ -85,6 +85,10 @@ class Api extends Transport $res = $client->request('PUT', $host, $request_opts); } else { //Method POST $request_opts['form_params'] = $query; + foreach ($query as $metric => $value) { // replace all variables defined in Options and found in Body for their values + $body = str_replace('{{ $' . $metric . ' }}', $value, $body); + } + $request_opts['body'] = $body; $res = $client->request('POST', $host, $request_opts); }