CMDB Instance REST API is failing with "error": "MISSING_DEPENDENCY". Need help

duraisdm
Giga Contributor

Hi Team,

I'm new to servicenow and working on automating CI items by leveraging CMDB REST APIs. While I was testing sample API operations, POST call to CMDB CI is failing with below error.

{
"result": {
"items": [
{
"className": "cmdb_ci_netapp_svm",
"sysId": "Unknown",
"identifierEntrySysId": "Unknown",
"errors": [
{
"error": "MISSING_DEPENDENCY",
"message": "In payload no relations defined for dependent class [cmdb_ci_netapp_svm] that matches any containment/hosting rules: [cmdb_ci_netapp_datacenter <- Contains <- cmdb_ci_netapp_svm]. Add appropriate relations in payload for '{\"className\":\"cmdb_ci_netapp_svm\",\"values\":{\"Manufacturer\":\"NetApp\",\"Asset\":\"1239823469234792349 - NetApp\",\"Asset tag\":\"FAS8000\",\"Name\":\"svm01\"},\"internal_id\":\"ad0dc3052e94311093b2acf40a475ac5\",\"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"
],
"hybridEntryCiAttributes": [],
"searchOnTable": "sys_object_source"
}
],
"info": [],
"inputIndices": [
0
],
"mergedPayloadIds": [],
"warningCount": 0,
"markers": [],
"errorCount": 2
}
],
"additionalCommittedItems": [],
"relations": [],
"additionalCommittedRelations": [],
"hasError": true,
"hasWarning": false,
"logContextId": "210dc30597943110efdef980f053afc6"
}
}

Payload I used.

{
"outbound_relations": [],
"inbound_relations": [],
"attributes": {
"Asset": "1239823469234792349 - NetApp",
"Asset tag": "FAS8000",
"Name": "svm01",
"Manufacturer": "NetApp"
},
"source": "ServiceNow"
}
 
I'm not sure what has to be done. Could you please help me with this?
4 REPLIES 4

Ratnakar7
Mega Sage
Mega Sage

Hi @duraisdm ,

 

The error message you are encountering indicates that there is a missing dependency in the payload you are sending to the CMDB CI API. Specifically, it states that there are no relations defined for the dependent class "cmdb_ci_netapp_svm" that match any containment/hosting rules: [cmdb_ci_netapp_datacenter <- Contains <- cmdb_ci_netapp_svm].

To resolve this issue, you need to include the appropriate relations in the payload for the dependent class "cmdb_ci_netapp_svm". This involves specifying the relationships between the CI records you are creating in your payload.

The payload you provided seems to be missing the relations data. To fix this, you can modify your payload as follows:

{
  "outbound_relations": [
    {
      "type": "Contains",
      "target_class": "cmdb_ci_netapp_datacenter",
      "attributes": {
        "source": "ServiceNow"
      }
    }
  ],
  "inbound_relations": [],
  "attributes": {
    "Asset": "1239823469234792349 - NetApp",
    "Asset tag": "FAS8000",
    "Name": "svm01",
    "Manufacturer": "NetApp"
  },
  "source": "ServiceNow"
}

 

In this modified payload, we have added an "outbound_relation" with the type "Contains" and the target class "cmdb_ci_netapp_datacenter". This indicates that the "cmdb_ci_netapp_datacenter" CI contains the "cmdb_ci_netapp_svm" CI. Additionally, we have included the "attributes" data for the "outbound_relation".

Please note that the specific relation types and target classes may vary based on your CMDB configuration. Make sure to adjust the payload according to the containment/hosting rules and relationships defined in your CMDB.

After updating the payload with the appropriate relations, you can try making the POST call to the CMDB CI API again. It should now create the CI item with the correct relationships and resolve the "MISSING_DEPENDENCY" error.

 

Thanks,

Ratnakar

Hi @Ratnakar7 ,

 

Thanks for update. I tried the payload you provided, but it is failing with below error.

 

 

{
"error": {
"message": "Invalid Relation Entry",
"detail": "outbound relation provided with empty target sys id and relation type Contains"
},
"status": "failure"
}

 

 
I referred API document link https://docs.servicenow.com/bundle/utah-api-reference/page/integrate/inbound-rest/concept/cmdb-insta....
Based on it I tried revising the payload as below.

 

{
  "outbound_relations": [
    {
      "type": "55c95bf6c0a8010e0118ec7056ebc54d",
      "target": "c5ffae4997143110efdef980f053afb3"
    }
  ],
  "inbound_relations": [],
  "attributes": {
    "Asset": "1239823469234792349 - NetApp",
    "Asset tag": "FAS8000",
    "Name": "svm01",
    "Manufacturer": "NetApp"
  },
  "source": "ServiceNow"
}

 

 

This time I'm getting new error as below.

 

"errors": [
                    {
                        "error": "METADATA_RULE_MISSING",
                        "message": "No containment or hosting rules defined for dependent class [cmdb_ci_netapp_datacenter]. Add containment/hosting rules for '{\"className\":\"cmdb_ci_netapp_datacenter\",\"values\":{\"Manufacturer\":\"NetApp\",\"Asset\":\"1239823469234792349 - NetApp\",\"Asset tag\":\"FAS8000\",\"Name\":\"svm01\"},\"internal_id\":\"dd7723e6b6103110ebc64f6888e082e6\",\"sys_object_source_info\":{},\"settings\":{},\"sys_ire_info\":{},\"display_values\":{}}'"
                    },
                    {
                        "error": "ABANDONED",
                        "message": "Too many other errors"
                    }
                ],

 



Hi @duraisdm ,

 

It seems like the relation data is still not correct. Based on the error message you provided, it indicates that there are no containment or hosting rules defined for the dependent class "cmdb_ci_netapp_datacenter".

To resolve this issue, you need to identify the correct relation type and target class that represents the containment or hosting relationship between "cmdb_ci_netapp_datacenter" and "cmdb_ci_netapp_svm" CIs in your CMDB configuration.

You can try the following steps to find the correct relation type and target class:

  1. Navigate to "Configuration" > "CI Relationships" > "Relationship Types" in your ServiceNow instance.

  2. Look for the relationship type that represents the containment or hosting relationship between "cmdb_ci_netapp_datacenter" and "cmdb_ci_netapp_svm" CIs.

  3. Take note of the sys_id of the relationship type and the target class sys_id.

  4. Update your payload with the correct relation type sys_id and target class sys_id:

{
  "outbound_relations": [
    {
      "type": "<relationship_type_sys_id>",
      "target": "<cmdb_ci_netapp_datacenter_sys_id>"
    }
  ],
  "inbound_relations": [],
  "attributes": {
    "Asset": "1239823469234792349 - NetApp",
    "Asset tag": "FAS8000",
    "Name": "svm01",
    "Manufacturer": "NetApp"
  },
  "source": "ServiceNow"
}

Replace "<relationship_type_sys_id>" and "<cmdb_ci_netapp_datacenter_sys_id>" with the actual sys_ids you found in step 3.

After making these changes, try making the POST call to the CMDB CI API again. It should now create the CI item with the correct relationships and resolve the "METADATA_RULE_MISSING" error.

 

Thanks,

Ratnakar

Hi @Ratnakar7,

I'm unable to find the Navigation Menu "Configuration" > "CI Relationships" > "Relationship Types" in my servicenow instance. Am I doing something wrong? or looking at wrong place?