Trying to do an integration to a SMS provider and using the standard API form in Alert Transports.
Tested using curl, and everything works, but cannot seem to get my head around the structure when defining the API Transport.
So - This works:
curl -X POST -H “Authorization: Basic auth-string==” -d ’
{
“to”:“MYPHONE”, “message”: “This is the message text body”, “from”: “SMS-GATEWAY”
}
’ "https://api.cpsms.dk/v2/send
When building this, I just paste that string into the body field.
In librenms.log, I get this error:
{“code”:400,“message”:“POST parameters is missing”}
Hi
I think the issue is simpler than this. BODY is not transmitted at all when the request is a POST request. Only for PUT we can see it. So you may try to add this at line 87:
Hi @Jens_Nykaer,
Did you manage to make it work? I am struggling with the same thing.
I manage to put the line in Api.php as suggested by @PipoCanaja and add the xml content in the body field, but the problem is that Libre is not resolving the variables in there:
} else { //Method POST
$request_opts['query'] = $query;
foreach ($query as $metric => $value) { // replace all variables defined in Options for and found in Body for their values
$body = str_replace( '$' . $metric, "$value" , $body);
}
// file_put_contents('/tmp/new_body.txt',print_r($body,true));
$request_opts['body'] = $body;
$res = $client->request('POST', $host, $request_opts);
}