User Tools

Site Tools


Sidebar

1.8:api:host:create

Table of Contents

create()

This method allows you to create a host as defined by the host data array.

Parameters

ParameterTypeOptionalDescriptionDetails
host dataarray or object No Array of Host objects or a single objecthostid shouldn't be specified
groupsarray No HostGroup Objects add Host to.
templatesarray No Templates Objects link Host to.

Returns

ParameterDescription
resultOperation successful. Result will contain array of created Host IDs. hostid are assigned to each Host object
errorIn case of any errors

Example

{
"jsonrpc":"2.0",
"method":"host.create",
"params":{
      "host":"Linux001",
      "ip":"192.168.3.1",
      "port":10050,
      "useip":1,
      "groups":[
         {
            "groupid":50
         }
      ],
      "templates":[
         {
            "templateid":20045
         }
      ]
   },
"auth":"038e1d7b1735c6a5436ee9eae095879e",
"id":3
}

Host added successfully:

{
"jsonrpc":"2.0",
"result":{
   "hostids": ["107819"]
},
"id":3
}

Host already exists:

{
"jsonrpc":"2.0",
"error":{
      "code":-32602,
      "message":"Invalid params.",
      "data":"[ CHost::create ] Host [ Linux001 ] already exists"
},
"id":3
}