Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to create CMDB Ci Relationships depens on::Used by or managed by, by using the OOB API call

Avinash_M
Tera Contributor

Hello Team,

We are using a completely out‑of‑the‑box (OOB) instance. Through a workflow, I am trying to create Configuration Items (CIs) and CI relationships using the REST API. I am able to successfully create CI records via the workflow using a service account with the ITIL role. However, I am unable to create CI relationships. Could you please suggest the best OOB approach to create CI relationships in this scenario?

1.I'm using the below endpoint to create a CI record
Endpoint:  https://myinstance.service-now.com/api/now/identifyreconcile (POST Method)
Basic Authentication via service account
Payload:

{
 
"items":[
  {
   "className":"cmdb_ci_linux_server",
       "values":{
"comments": "Table API Test",
"company": "Mycompany",
"environment": "Development",
"name":  "iaastestci11",
"operational_status":  "5",
"serial_number": "AARON-API-TEST-T01",
"support_group": "Test-SUPPORT",
        "discovery_source": "ServiceNow"
     
   }
  }
]
}
By using the above data I'm able to create CI record. 
2.Endpoint:https://myinstanceservice-now.com/api/now/v1/table/cmdb_rel_ci
Payload:
{
"parent": "${parent}",
"child": "${child}",
"type": "${type}"
 
}
Response I got: {"error":{"message":"Operation Failed","detail":"Operation against file 'cmdb_rel_ci' was aborted by Business Rule 'Prevent Recursion in CI Relationships^a49888ee2f2376145f4c444bcfa4e36a'. Business Rule Stack:Prevent Recursion in CI Relationships"},"status":"failure"}
- So the relationship was aborted by OOB Business rule, it should abort when the child and parent is equal, but in my scenario both are not same.

-3.And I have tried to create CI and relationships in a single REST call by using the below data
Endpoint: https://myinstance.service-now.com/api/now/identifyreconcile (POST Method)
Payload:
{
"items": [
{
"className": "cmdb_ci_win_server",
"values": {
"name": "TEST-SERVER-01",
"serial_number": "SRV12345",
"operational_status": 1,
"discovery_source": "Other Automated"
},
"sys_object_source_info": {
"source_name": "Integration",
"source_native_key": "SERVER-001"
}
},
{
"className": "cmdb_ci_appl",
"values": {
"name": "Test App",
"appl_id": "APP-001",
"discovery_source": "Other Automated"
},
"sys_object_source_info": {
"source_name": "Integration",
"source_native_key": "APP-001"
}
}
],
"relations": [
{
"parent": 1,
"child": 0,
"type": "Runs on::Runs"
}
]
}
Response:
{"result":{"items":[{"identifierEntrySysId":"Unknown","identificationAttempts":[{"info":"sys_object_source NO_MATCH","identifierName":"","attemptResult":"NO_MATCH","searchOnTable":"sys_object_source","attributes":["source_name","source_native_key"]},{"identifierName":"Hardware Rule","attemptResult":"SKIPPED","hybridEntryCiAttributes":[],"searchOnTable":"cmdb_ci_hardware","attributes":["product_instance_id"]},{"identifierName":"Hardware Rule","attemptResult":"SKIPPED","hybridEntryCiAttributes":[],"searchOnTable":"cmdb_serial_number","attributes":["serial_number","serial_number_type"]},{"identifierName":"Hardware Rule","attemptResult":"NO_MATCH","hybridEntryCiAttributes":[],"searchOnTable":"cmdb_ci_hardware","attributes":["serial_number"]},{"identifierName":"Hardware Rule","attemptResult":"NO_MATCH","hybridEntryCiAttributes":[],"searchOnTable":"cmdb_ci_hardware","attributes":["name"]},{"identifierName":"Hardware Rule","attemptResult":"SKIPPED","hybridEntryCiAttributes":[],"searchOnTable":"cmdb_ci_network_adapter","attributes":["mac_address","name"]}],"info":[],"errorCount":1,"markers":[],"mergedPayloadIds":[],"warningCount":0,"inputIndices":[0],"className":"cmdb_ci_win_server","errors":[{"error":"INSERT_FAILED","message":"Insertion failed with error: Commit was not attempted due to other errors"}]},{"identifierEntrySysId":"Unknown","identificationAttempts":[{"info":"sys_object_source NO_MATCH","identifierName":"","attemptResult":"NO_MATCH","searchOnTable":"sys_object_source","attributes":["source_name","source_native_key"]}],"info":[],"errorCount":2,"markers":[],"mergedPayloadIds":[],"warningCount":0,"inputIndices":[1],"className":"cmdb_ci_appl","sysId":"Unknown","errors":[{"error":"MISSING_MATCHING_ATTRIBUTES","message":"In payload missing minimum set of input values for criterion (matching) attributes from identify rule for table [cmdb_ci_appl]. Add these input values in payload item '{\"className\":\"cmdb_ci_appl\",\"values\":{\"discovery_source\":\"Other Automated\",\"appl_id\":\"APP-001\",\"name\":\"Test App\"},\"internal_id\":\"fc4d29a229ebbe14da278df5442bc33e\",\"sys_object_source_info\":{\"source_name\":\"Integration\",\"source_native_key\":\"APP-001\"},\"settings\":{},\"sys_ire_info\":{},\"display_values\":{}}'"},{"error":"ABANDONED","message":"Too many other errors"}]}],"additionalCommittedItems":[],"relations":[{"identifierEntrySysId":"Unknown","errorCount":1,"markers":[],"mergedPayloadIds":[],"warningCount":0,"inputIndices":[0],"className":"cmdb_rel_ci","sysId":"Unknown","errors":[{"error":"ABANDONED","message":"Too many other errors"}]}],"additionalCommittedRelations":[],"hasError":true,"hasWarning":false,"logContextId":"f44d29a22febbe1425fbd44bcfa4e33f"}}

- So pls verify and suggest the best OOB approach.

Thanks,
Avinash

0 REPLIES 0