Ad Widget

Collapse

create.host API doesn't add to multiple groups

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • linuxgurugamer
    Member
    • Oct 2010
    • 66

    #1

    create.host API doesn't add to multiple groups

    I'm working on a script to automatically create hosts. It works, and now I'm trying to get it to add the server to more than one group.

    It only adds the server to the last group listed in the groups section.

    Here is the code which is being used to create the host:

    This is being done in bash

    Json code is built up in a variable called $data:

    {"jsonrpc":"2.0","method":"host.create","params":{ "host":"zabbix4loadtest.xxxxxxxxx.com","interfaces ":[{"type":1,"main":1,"ip":"192.168.102.222","dns":"z abbix4loadtest.kidbiz3000.com","port":10050,"useip ":0}],"groups":[{"groupid":7,"groupid":11,"groupid":4,"groupid":15 }],"templates":[{"templateid":10132}]},"auth":"0126382d673193f1759f6141275dbb91","id":0 }


    and here is the code to do the call itself:

    curl -i -X POST -H 'Content-Type: application/json-rpc' -d $data $API

    Is this a limitation of the API? Or is it a bug?

    Thanks in advance



    JBB
  • linuxgurugamer
    Member
    • Oct 2010
    • 66

    #2
    Never mind, it was a syntax error.


    JBB

    Comment

    • Javier
      Member
      Zabbix Certified Specialist
      • Jan 2010
      • 58

      #3
      You need pass group array so,

      "groups":[
      {"groupid":4},
      {"groupid":7},
      {"groupid":11},
      {"groupid":15 }
      ],

      For templates, the same...

      Comment

      Working...