Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-12347

Problem with GroupID to create host in Zabbix API

    XMLWordPrintable

Details

    • Incident report
    • Status: Closed
    • Critical
    • Resolution: Workaround proposed
    • 3.2.6
    • None
    • API (A)
    • None
    • Ubuntu Server 2016 LTS, Poweshell, Windows 10

    Description

      Hi everybody,

      I've made an script in powershell to add a automatically Host, Host Group, and more when I install zabbix agent in a server, that it is automated as well.

      The problem is when I try to create a new host, specially when the API gets the ID of hostgroup, zabbix api only gets one number of the ID, for example if you put: groupid='40' the api will take only 4...

      This problem restric to use only 1 digit (1 to 9).

      Here is the code of the JSON request:

      $params = @{
      body = @{
      jsonrpc= "2.0"
      method= "host.create"
      params= @{
      host="test001"
      interfaces = @

      { type=1 main=1 useip=1 ip= "127.0.0.1" dns="test.serv" port=10050 }


      "groups"= @

      { groupid="40" }

      }
      "id"= 7
      "auth"= $auth
      } | ConvertTo-Json
      uri = "example.zabix.com/api_jsonrpc.php"
      headers = @

      {"Content-Type" = "application/json"}

      method = "Post"
      }
      $result = Invoke-WebRequest @params
      echo $result | ConvertFrom-Json

      And I Added a variable in the error to display the value of the ID received and this is the result:

      PS C:\Users\user> echo $result | ConvertFrom-Json

      jsonrpc
      id error
      ------- ----- –
      2.0 @

      {code=-32500; message=Application error.; data=**GroupValue: 4** No permissions to referred object or it does not exist!; debug=System.Object[]}

      4

      I sent 40 and I recived *GroupValue: 4*

      Thanks people!

      Attachments

        Activity

          People

            Unassigned Unassigned
            zhelix David Rodriguez Martinez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: