Hi,
I'm working on an automate to add host in zabbix. I use API but I have a problem beetween two request very similar.
The first one is :
{"jsonrpc":"2.0","method":"host.create","params":{ "host":"localhost","interfaces":{"type":1,"main":1 ,"useip":0,"ip":"127.0.0.1","dns":"localhost","por t":"10050"},"groups":{"groupid":"2"},"templates":{ "templateid":"10001"}},"auth":"ede78a7c25cd00bc3ef acf68a6a04051","id":"13548799648877"}
and return OK
{"jsonrpc":"2.0","result":{"hostids":["10147"]},"id":"13548799648877"}
but the second one :
{"jsonrpc":"2.0","method":"host.create","params":{ "host":"jkdmsklqxq","interfaces":{"type":1,"main": 1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.jms p.prod","port":"10050"},"groups":{"groupid":"27"}, "templates":{"templateid":"10001"}},"auth":"9424af 3de542f831db97c7151fb0fa25","id":"13548800841662"}
return KO (debug is activated)
{"jsonrpc":"2.0","error":{"code":-32500,"message":"Application error.","data":"No permissions to referred object or it does not exist!","debug":[{"file":"\/usr\/share\/zabbix\/api\/classes\/CHost.php","line":1318,"function":"exception","cla ss":"CZBXAPI","type":"::","args":[120,"No permissions to referred object or it does not exist!"]},{"file":"\/usr\/share\/zabbix\/api\/classes\/CHost.php","line":1466,"function":"checkInput","cl ass":"CHost","type":"->","args":[[{"host":"jkdmsklqxq","interfaces":{"type":1,"main" :1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.jm sp.prod","port":"10050"},"groups":{"groupid":"27"} ,"templates":{"templateid":"10001"},"name":"jkdmsk lqxq"}],"create"]},{"function":"create","class":"CHost","type":"->","args":[{"host":"jkdmsklqxq","interfaces":{"type":1,"main" :1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.jm sp.prod","port":"10050"},"groups":{"groupid":"27"} ,"templates":{"templateid":"10001"}}]},{"file":"\/usr\/share\/zabbix\/api\/rpc\/class.czbxrpc.php","line":107,"function":"call_use r_func","args":[[{},"create"],{"host":"jkdmsklqxq","interfaces":{"type":1,"main ":1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.j msp.prod","port":"10050"},"groups":{"groupid":"27" },"templates":{"templateid":"10001"}}]},{"file":"\/usr\/share\/zabbix\/api\/rpc\/class.czbxrpc.php","line":65,"function":"callAPI", "class":"czbxrpc","type":"::","args":["host.create",{"host":"jkdmsklqxq","interfaces":{" type":1,"main":1,"useip":0,"ip":"127.0.0.5","dns": "jkdmsklqxq.jmsp.prod","port":"10050"},"groups":{" groupid":"27"},"templates":{"templateid":"10001"}}]},{"file":"\/usr\/share\/zabbix\/api\/rpc\/class.cjsonrpc.php","line":66,"function":"call","c lass":"czbxrpc","type":"::","args":["host.create",{"host":"jkdmsklqxq","interfaces":{" type":1,"main":1,"useip":0,"ip":"127.0.0.5","dns": "jkdmsklqxq.jmsp.prod","port":"10050"},"groups":{" groupid":"27"},"templates":{"templateid":"10001"}} ,"9424af3de542f831db97c7151fb0fa25"]},{"file":"\/usr\/share\/zabbix\/api_jsonrpc.php","line":54,"function":"execute","c lass":"CJSONrpc","type":"->","args":[]}]},"id":"13548800841662"}
The group is correct and i use superadministrator group for logging so right restriction.
I don't find what is the mistake between this two requests.
Somebody have some idea??
Thank' all lot for your help.
I'm working on an automate to add host in zabbix. I use API but I have a problem beetween two request very similar.
The first one is :
{"jsonrpc":"2.0","method":"host.create","params":{ "host":"localhost","interfaces":{"type":1,"main":1 ,"useip":0,"ip":"127.0.0.1","dns":"localhost","por t":"10050"},"groups":{"groupid":"2"},"templates":{ "templateid":"10001"}},"auth":"ede78a7c25cd00bc3ef acf68a6a04051","id":"13548799648877"}
and return OK
{"jsonrpc":"2.0","result":{"hostids":["10147"]},"id":"13548799648877"}
but the second one :
{"jsonrpc":"2.0","method":"host.create","params":{ "host":"jkdmsklqxq","interfaces":{"type":1,"main": 1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.jms p.prod","port":"10050"},"groups":{"groupid":"27"}, "templates":{"templateid":"10001"}},"auth":"9424af 3de542f831db97c7151fb0fa25","id":"13548800841662"}
return KO (debug is activated)
{"jsonrpc":"2.0","error":{"code":-32500,"message":"Application error.","data":"No permissions to referred object or it does not exist!","debug":[{"file":"\/usr\/share\/zabbix\/api\/classes\/CHost.php","line":1318,"function":"exception","cla ss":"CZBXAPI","type":"::","args":[120,"No permissions to referred object or it does not exist!"]},{"file":"\/usr\/share\/zabbix\/api\/classes\/CHost.php","line":1466,"function":"checkInput","cl ass":"CHost","type":"->","args":[[{"host":"jkdmsklqxq","interfaces":{"type":1,"main" :1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.jm sp.prod","port":"10050"},"groups":{"groupid":"27"} ,"templates":{"templateid":"10001"},"name":"jkdmsk lqxq"}],"create"]},{"function":"create","class":"CHost","type":"->","args":[{"host":"jkdmsklqxq","interfaces":{"type":1,"main" :1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.jm sp.prod","port":"10050"},"groups":{"groupid":"27"} ,"templates":{"templateid":"10001"}}]},{"file":"\/usr\/share\/zabbix\/api\/rpc\/class.czbxrpc.php","line":107,"function":"call_use r_func","args":[[{},"create"],{"host":"jkdmsklqxq","interfaces":{"type":1,"main ":1,"useip":0,"ip":"127.0.0.5","dns":"jkdmsklqxq.j msp.prod","port":"10050"},"groups":{"groupid":"27" },"templates":{"templateid":"10001"}}]},{"file":"\/usr\/share\/zabbix\/api\/rpc\/class.czbxrpc.php","line":65,"function":"callAPI", "class":"czbxrpc","type":"::","args":["host.create",{"host":"jkdmsklqxq","interfaces":{" type":1,"main":1,"useip":0,"ip":"127.0.0.5","dns": "jkdmsklqxq.jmsp.prod","port":"10050"},"groups":{" groupid":"27"},"templates":{"templateid":"10001"}}]},{"file":"\/usr\/share\/zabbix\/api\/rpc\/class.cjsonrpc.php","line":66,"function":"call","c lass":"czbxrpc","type":"::","args":["host.create",{"host":"jkdmsklqxq","interfaces":{" type":1,"main":1,"useip":0,"ip":"127.0.0.5","dns": "jkdmsklqxq.jmsp.prod","port":"10050"},"groups":{" groupid":"27"},"templates":{"templateid":"10001"}} ,"9424af3de542f831db97c7151fb0fa25"]},{"file":"\/usr\/share\/zabbix\/api_jsonrpc.php","line":54,"function":"execute","c lass":"CJSONrpc","type":"->","args":[]}]},"id":"13548800841662"}
The group is correct and i use superadministrator group for logging so right restriction.
I don't find what is the mistake between this two requests.
Somebody have some idea??
Thank' all lot for your help.
Comment