Create cmdb_ci_server via API and relationship to service instance

prinand
Tera Contributor

I am creating a new CI as part of a server build process.
I can create the server CI and separately create a relationship to a service instance.
but I see examples where I get the impression as if you can create the server CI and relationship (to existing service instance) but I cannot get that to work. 

this a part of the JSON body:
{
"name": "AndreTest013",
"fqdn": "AndreTest013.mydomain.com",
"serial_number": "VMware-12 cc cc dd ee ff 00 11-22 33 44 55 66 77 88 99"
}
and then I post that, the CI is created.

the examples I see also show this JSON format that include a section for inbound and outbound relations:
{
"name": "AndreTest013",
"fqdn": "AndreTest014.mydomain.com",
"serial_number": "VMware-12 cc cc dd ee ff 00 11-22 33 44 55 66 77 88 99",
"inbound_relations": [
      {

            "type" : "Depends on::Used by",

            "target": "1a9cb166f1571100a92eb60da2bce5c5"

     }

]

}

(and I tried for type and target both the name value and the sys_id)

 

but it does not work for me. the CI is created, but not the relationship.... (no error either, that section is just ignored)

this is what the result is when I get the CI that I created:

PS C:\Users\andre> $rec.inbound_relations

PS C:\Users\andre> $rec.outbound_relations

PS C:\Users\andre> $rec.attributes

sys_class_name : cmdb_ci_server
serial_number : VMware-13 cc cc dd ee ff 00 11-22 33 44 55 66 77 88 99
name : AndreTest013

if I query the same on another CI I created but where I separately created the relationship, it will show under inboud_relations.


so my question is: is it possible to create the relationship in one single JSON body when creating the server CI, or is that not possible ??

3 REPLIES 3

Di Zhang
Tera Guru

try integrationHUB ETL. IntegrationHub ETL (3.2)

Di Zhang
Tera Guru

Identification and Reconciliation engine (IRE)

Here is code for reference:

 

Server/Computer feed:
{
"items": [
{
"className": "cmdb_ci_linux_server",
"values": { "name": 'linux001',
"ip_address": "100.126.38.19",
"mac_address": "DSWER4587" },
"sys_object_source_info": {
"source_native_key": "Server001",
"source_name": "SCCM",
"source_feed": "COMPUTER_IDENTITY",
"source_recency_timestamp": "2019-08-26 14:00:00"
}
}
]
}

Di Zhang
Tera Guru