Ad Widget

Collapse

version 5.0 API (host.create)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VojuCZ
    Junior Member
    • Dec 2016
    • 7

    #1

    version 5.0 API (host.create)


    Hello,
    can somebody help? I can login, I can send host.get method and everything is OK. But host.create response me with error :
    Code:
    {
     "jsonrpc":"2.0",
     "method":"host.create",
     "params":{
       "host": "10.200.200.6",
       "interfaces": [
        {
         "type":2,
         "main":1,
         "useip": 1,
         "ip": "10.200.200.6",
         "dns":"",
         "port": "161"
        }
       ],
       "groups": [
        {
         "groupid": "25"
        }
       ],
       "templates": [
        {
         "templateid": "10325"
        }
       ]
     },
     "auth":"aede2d39b8772ec317fad1cfbb1b90e6",
     "id":1
    }
    Response:
    Code:
    {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Incorrect arguments passed to function."},"id":1}
    Can somebody help ? groupid and templateid are correct (.../zabbix/hostgroups.php?form=update&groupid=25 and .../zabbix/templates.php?form=update&templateid=10325 exists). Version 5.0 on Ubuntu 18.04.4

    Thank you
  • VojuCZ
    Junior Member
    • Dec 2016
    • 7

    #2
    More "tests" trying resolve this problem:
    1.) API user account has full permissions: usertype Zabbix Super Admin, All groups read-write permissions.
    2.) Also tried login to API with Admin user, It didn't help
    3.) Changing interfaces - type to 1 get new error - "Cannot find interface on ...." - due to lack od SNMP interface. Because of this error I suppose, that formating of request string is no problem (big whitespaces, tabs...)
    4.) I get same Error "Incorrect arguments passed to function" when changing Interfaces main parameter to 0 or 1
    5.) When deleting templates [ templateid... ] parameters, still same error


    Comment

    • nazabal
      Junior Member
      • May 2020
      • 1

      #3
      Hi VojuCZ,
      I had exactly the same problem, I just solved by checking the documentation, in Zabbix 4.4 it works fine but in 5.0 you will need to include the "details" parameter to specify the SNMP properties.
      Here is the Host Interface documentation: https://www.zabbix.com/documentation...terface/object

      Example:
      Code:
      {
          "jsonrpc": "2.0",
          "method": "host.create",
          "params": {
              "host": "10.200.200.6",
              "interfaces": [
                  {
                      "type": 2,
                      "main": 1,
                      "useip": 1,
                      "ip": "10.200.200.6",
                      "dns": "",
                      "port": "161",
                      "details": {
                          "version": 2,
                          "community": "public"
                      }
                  }
              ],
              "groups": [
                  {
                      "groupid": "25"
                  }
              ],
              "templates": [
                  {
                      "templateid": "10325"
                  }
              ]
          },
          "auth": "aede2d39b8772ec317fad1cfbb1b90e6",
          "id": 1
      }

      Comment

      • VojuCZ
        Junior Member
        • Dec 2016
        • 7

        #4
        Hello,
        thank you for your help. With "details" parameter it is working fine :-)

        Comment

        Working...