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>
This commit is contained in:
mzacchi 2021-08-28 23:19:06 +02:00 committed by GitHub
parent d646562e4e
commit 71cd81269a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}