Ad Widget

Collapse

api host create

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FleZzz
    Junior Member
    • May 2012
    • 10

    #1

    api host create

    hi, have a trouble with creating host in api
    here my request:
    $json = {
    jsonrpc => '2.0',
    method => 'host.create',
    params => {
    host => 'test_from_api',
    output => 'extend',
    interfaces => {
    dns => '',
    hostid => '25',
    ip => '127.0.0.1',
    main => '1',
    port => '10050',
    type => '1',
    useip => '1',
    },
    groups => {

    groupid => '2', #Linux Servers
    },
    },
    auth => "$authID",
    id => '2',
    };

    and im get it:

    'version' => 0,
    'content' => {
    'jsonrpc' => '2.0',
    'id' => '21',
    'result' => {
    'hostids' => [
    '34'
    ]
    }
    },
    'jsontext' => '{"jsonrpc":"2.0","result":{"hostids":["34"]},"id":"21"}',
    'is_success' => 1
    }, 'JSON::RPC::ReturnObject' );

    all ok, i see new host in web interface, delete it... and now im trying to create host in groupid 24 (it`s already exist!!!)

    same request, but groupid => '24'
    now i get a lot of words in answer the main is:

    "code":-32500,"message":"Application error.","data":"No permissions to referred object or it does not exist!"

    what is this!? why i can`t to create host in groupid 24?!
  • Pavels
    Member
    • Oct 2011
    • 83

    #2
    The user you're loggin in with probably doesn't have write permissions to the host group.

    Comment

    • FleZzz
      Junior Member
      • May 2012
      • 10

      #3
      no... its some kind of bug...
      correctly request is

      groups => [{
      groupid => '2', #Linux Servers
      }],

      Comment

      • Pavels
        Member
        • Oct 2011
        • 83

        #4
        Could you try to call hostgroup.get and post the response here to make sure that the group is editable? Use the following parameters:

        {
        "editable": true,
        "groupids": 24
        }

        Comment

        • FleZzz
          Junior Member
          • May 2012
          • 10

          #5
          thanks, i'm already solved the problem

          Comment

          Working...