mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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 <[email protected]>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user