January 2019
Intermediate to advanced
798 pages
20h 33m
English
Before we can perform any useful operations through the API, we must log in. Our JSON string would be as follows:
$ json='{"jsonrpc":"2.0","method":"user.login","id":2,"params":{"user":"Admin","password":"zabbix"}}'
Now, run the curl command to get the API version. In all further API requests, we'll only change the json variable and then reuse the same curl command:
$ curl -s -w '\n' -X POST -H 'Content-Type: application/json-rpc' -d "$json" http://localhost/zabbix/api_jsonrpc.php
In this case, assuming a correct username and password, it should return the following:
{"jsonrpc":"2.0","result":"df83119ab78bbeb2065049412309f9b4","id":2}
Read now
Unlock full access