Ad Widget

Collapse

Problems with responses from json API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phboos
    Junior Member
    • Feb 2021
    • 1

    #1

    Problems with responses from json API

    Hello,

    i'm trying to get a connection over the api_jsonrpc.php to work, but stuck after the authentification

    I'm able to connect to the api:

    Code:
    bash# curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"apiinfo.version","id": 1,"auth":null,"params":{}}' 'http://x.x.x.x/api_jsonrpc.php' | jq '.'
    {
    "jsonrpc": "2.0",
    "result": "5.2.4",
    "id": 1
    }
    and i can do an authentification:

    Code:
    bash# curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{ "params": { "user": "MyUser", "password": "myPassword" }, "jsonrpc": "2.0", "method": "user.login", "id": 0 }' 'http://x.x.x.x/api_jsonrpc.php' | jq '.'
    {
    "jsonrpc": "2.0",
    "result": "bcd0f4a3295dbc788045cf05139xxxxx",
    "id": 0
    }
    but when i want to get the hostgroups or the hosts, i get an empty response back:


    Code:
    bash# curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"hostgroup.get","id":1, "auth":"bcd0f4a3295dbc788045cf05139xxxxx","params" :{}}' 'http://x.x.x.x/api_jsonrpc.php' | jq '.'
    {
    "jsonrpc": "2.0",
    "result": [],
    "id": 1
    }
    bash curl -s -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"host.get","id":1,"auth ":"bcd0f4a3295dbc788045cf05139xxxxx","params": {}}' 'http://x.x.x.x/api_jsonrpc.php' | jq '.'
    {
    "jsonrpc": "2.0",
    "result": [],
    "id": 1
    }
    the User is allowed to access the API, hosts and hostgroups are configured in Zabbix.

    There is now error related to json or api in the zabbix_server.log

    Anyone has a hint, where i can look at or where the Problem is?

    I'm running the actual zabbix 5.2.4 on Ubuntu 20.04.01 LTS on arm64, installed via the scripts from the zabbix.com/downloads page

    thx for your support
Working...