We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to create CMDB CI Relationship via OOB REST API call

Avinash_M
Tera Contributor

Hello Team, 

I want to create a CI record through a workflow using a service account with the ITIL role. Since we are using a completely out-of-the-box (OOB) instance, I am looking to create CI relationships using the OOB REST API. Could you please guide me on how to achieve this? Below, I have outlined all the details of what I have tried so far.

Trail 1: Endpoint Post call - "https://myinstance.service-now.com/api/now/table/cmdb_rel_ci" 

 

Payload:

{
  "parent": "${parent}",
  "child": "${child}",
  "type": "${type}"

}

 

Response:

 

{"error":{"message":"Operation Failed","detail":"Operation against file 'cmdb_rel_ci' was aborted by Business Rule 'Prevent Recursion in CI Relationships^3faa8c622fe73a1425fbd44bcfa4e354'. Business Rule Stack:Prevent Recursion in CI Relationships"},"status":"failure"}

 

Trail 2: https://myinstance.service-now.com/api/now/identifyreconcile

 

payload:

 

{
  "items": [
    {
      "className": "cmdb_ci_win_cluster",
      "values": {
        "name": "CLUSTER-01",
        "serial_number": "CL12345",
        "discovery_source": "Other Automated"
      },
      "relations": [
        {
          "type": "Depends on::Used by",
          "target": {
            "className": "cmdb_ci_appl",
            "values": {
              "name": "APP-SERVICE-01"
            }
          }
        }
      ]
    }
  ]
}

CI record is created but relationships are not created.

Response: 

 

{"result":{"items":[{"identifierEntrySysId":"Unknown","identificationAttempts":[{"info":"sys_object_source SKIPPED","identifierName":"","attemptResult":"SKIPPED","searchOnTable":"sys_object_source","attributes":["source_name","source_native_key"]},{"identifierName":"OS Cluster","attemptResult":"NO_MATCH","hybridEntryCiAttributes":[],"searchOnTable":"cmdb_ci_cluster","attributes":["cluster_id","name"]}],"info":[],"errorCount":0,"markers":[],"mergedPayloadIds":[],"warningCount":0,"inputIndices":[0],"className":"cmdb_ci_win_cluster","operation":"INSERT","sysId":"2f88f4222f6bfa142b1f4f5bf3878ea9"}],"additionalCommittedItems":[],"relations":[],"additionalCommittedRelations":[],"hasError":false,"hasWarning":false}}

-- https://myinstance.service-now.com/api/now/identifyreconcile - I can able to create a CI record by using this URL
Similarly, I want to create CI relationships pls guide me correct me if any URLs change and payload.


Thanks,
Avinash

1 REPLY 1

Tanushree Maiti
Tera Patron

Please refer this links, see if it helps you:

https://www.servicenow.com/community/cmdb-forum/establishing-ci-relationships-through-integration-am...

 

https://www.servicenow.com/community/developer-forum/creation-of-relationship-through-flow-desinger/...

 

https://www.servicenow.com/community/itsm-forum/how-to-provide-user-access-to-building-ci-relationsh...

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti