Dependent classes not working. CMDB Instance API; POST https://.service-now.com/api/now/cmdb/instance/ Create a record with associated relations;

pFog
Tera Contributor

The CMDB Instance API POST https://.service-now.com/api/now/cmdb/instance/ Create a record with associated relation endpoint works for classes that have no dependency. However I get this error when the class has a dependency and I can not figure out how to represent the dependency in the payload.

Endpoint:
/api/now/cmdb/instance/cmdb_ci_db_mssql_instance

Payload:
{
"outbound_relations":[],
"attributes":{
"name":"CI Test1",
"short_description":"The CMDB Instance API test of endpoint, Create a record with associated relations."
},
"source":"ServiceNow",
"inbound_relations":[]
}

Response:
{"result":{"items":[{"className":"cmdb_ci_db_mssql_instance","sysId":"Unknown","identifierEntrySysId":"Unknown","errors":[{"error":"MISSING_DEPENDENCY","message":"In payload no relations defined for dependent class [cmdb_ci_db_mssql_instance] that matches any containment/hosting rules: [cmdb_ci_appl >> Runs on >> cmdb_ci_hardware]. Add appropriate relations in payload for '{\"className\":\"cmdb_ci_db_mssql_instance\",\"values\":{\"short_description\":\"The CMDB Instance API test of endpoint, Create a record with associated relations.\",\"name\":\"CI Test1\",\"sys_class_name\":\"cmdb_ci_db_mssql_instance\"},\"internal_id\":\"d698984ca575115088d34112f2309fd6\",\"sys_object_source_info\":{},\"settings\":{},\"sys_ire_info\":{},\"display_values\":{}}'"},{"error":"ABANDONED","message":"Too many other errors"}],"identificationAttempts":[{"info":"sys_object_source SKIPPED","attemptResult":"SKIPPED","identifierName":"","attributes":["source_name","source_native_key"],"searchOnTable":"sys_object_source","hybridEntryCiAttributes":[]}],"info":[],"errorCount":2,"inputIndices":[0],"mergedPayloadIds":[],"markers":[],"warningCount":0}],"additionalCommittedItems":[],"relations":[],"additionalCommittedRelations":[],"hasError":true,"hasWarning":false,"logContextId":"da98984c97751150cdea75600153afd6"}}

For inbound/outbound relations I have tried combinations of
target:
type:

I do NOT know how to represent the missing dependency mentioned in the error response.

1 ACCEPTED SOLUTION

Madison2
Kilo Expert

The accepted solution in this post worked for me (add "depends_on" to the "inbound_relations")
https://www.servicenow.com/community/developer-forum/can-t-insert-cmdb-ci-storage-volume-ci-via-cmdb...

{
    "attributes": {
        "sys_class_name": "cmdb_ci_kubernetes_namespace",
        "name": "test-namespace-ci",
        "k8s_uid": "test-namespace-ci"
    },
    "source": "ServiceNow",
    "depends_on": {
        "inbound_relations": {
            "type": "55c95bf6c0a8010e0118ec7056ebc54d",
            "target": "3afa3dfe47e2595042d38e88436d43c1"
        }
    }
}



View solution in original post

1 REPLY 1

Madison2
Kilo Expert

The accepted solution in this post worked for me (add "depends_on" to the "inbound_relations")
https://www.servicenow.com/community/developer-forum/can-t-insert-cmdb-ci-storage-volume-ci-via-cmdb...

{
    "attributes": {
        "sys_class_name": "cmdb_ci_kubernetes_namespace",
        "name": "test-namespace-ci",
        "k8s_uid": "test-namespace-ci"
    },
    "source": "ServiceNow",
    "depends_on": {
        "inbound_relations": {
            "type": "55c95bf6c0a8010e0118ec7056ebc54d",
            "target": "3afa3dfe47e2595042d38e88436d43c1"
        }
    }
}