Hi,
I'm currently trying to use the zabbix api to get a list of all template names and id's, but unfortunately I'm getting the following response: {"jsonrpc":"2.0","result":[],"id":0}
An request looks ways like this:
Anyone has an idea what the problem is, or how I can debug this?
Best regards,
Fabian
I'm currently trying to use the zabbix api to get a list of all template names and id's, but unfortunately I'm getting the following response: {"jsonrpc":"2.0","result":[],"id":0}
An request looks ways like this:
Code:
class zabbix
{
private $authID = "<valid auth id>";
private $url = "<url zur api>"
private function sendRequest($data)
{
$query = json_encode($data);
echo $query."<br><br>";
$ch = curl_init($this->url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
return json_decode(curl_exec($ch), true);
}
public function getTemplates()
{
$request = array("jsonrpc" => "2.0",
"method" => "template.get",
"params" => array(
"output" => "simple",
"filter" => array(
"name" => array("Template OS Linux")
),
),
"id" => 0,
"auth" => $this->authID
);
print_r($this->sendRequest($request));
}
}
Best regards,
Fabian
Comment