I am trying to create a new host using the API. I am able to get information about an existing host, about maintenance groups, periods and more, but I get an error when I try to create the host.
$API_Host_Create = @{
jsonrpc = "2.0"
method = "host.create"
params = @{
host = "presaprsa2002v"
interfaces = @{
type = "1"
main = "1"
useip = "1"
ip = "10.163.121.92"
dns = "presaprsa2002v.xyz.com"
port = "10050"
}
groups = @{
groupid = "1085"
}
templates = @{
templateid = "24774"
}
}
auth = "$($auth_session)"
id = 1
}
function ESA_ZBX_HostCreate($hg_id, [boolean]$action, $ZAPI_Site)
{
$auth = zabbix_api($API_Login)
$auth_session = ($auth.result)
$API_Host_Create.auth = $auth_session
if ($auth.result)
{
#$($API_Host_Create | ConvertTo-Json) | out-file hanscreate.json
$zhostcreate = zabbix_api($API_Host_Create)
$hostcreate_error = $zhostcreate.error
$hostcreate_result = $zhostcreate.result
return $hostcreate_result.result
}
}
$Test = ESA_ZBX_HostCreate $DCE_SVS_id $true $DCE_A
NB! The parameters are not used at this moment.
Create result: @{code=-32500; message=Application error.; data=No permissions to referred object or it does not exist!}
I would very much appreciate suggestions on how to solve the problem. I am using Zabbix 4.4.
Thank you very much
$API_Host_Create = @{
jsonrpc = "2.0"
method = "host.create"
params = @{
host = "presaprsa2002v"
interfaces = @{
type = "1"
main = "1"
useip = "1"
ip = "10.163.121.92"
dns = "presaprsa2002v.xyz.com"
port = "10050"
}
groups = @{
groupid = "1085"
}
templates = @{
templateid = "24774"
}
}
auth = "$($auth_session)"
id = 1
}
function ESA_ZBX_HostCreate($hg_id, [boolean]$action, $ZAPI_Site)
{
$auth = zabbix_api($API_Login)
$auth_session = ($auth.result)
$API_Host_Create.auth = $auth_session
if ($auth.result)
{
#$($API_Host_Create | ConvertTo-Json) | out-file hanscreate.json
$zhostcreate = zabbix_api($API_Host_Create)
$hostcreate_error = $zhostcreate.error
$hostcreate_result = $zhostcreate.result
return $hostcreate_result.result
}
}
$Test = ESA_ZBX_HostCreate $DCE_SVS_id $true $DCE_A
NB! The parameters are not used at this moment.
Create result: @{code=-32500; message=Application error.; data=No permissions to referred object or it does not exist!}
I would very much appreciate suggestions on how to solve the problem. I am using Zabbix 4.4.
Thank you very much
Comment