CMDB Instance REST API is failing with "error": "MISSING_DEPENDENCY". Need help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 11:43 PM - edited ‎07-28-2023 12:05 AM
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.
Payload I used.
{
"outbound_relations": [],
"inbound_relations": [],
"attributes": {
"Asset": "1239823469234792349 - NetApp",
"Asset tag": "FAS8000",
"Name": "svm01",
"Manufacturer": "NetApp"
},
"source": "ServiceNow"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2023 04:42 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 12:46 AM
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"
}
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"
}
],
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 06:09 AM
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:
Navigate to "Configuration" > "CI Relationships" > "Relationship Types" in your ServiceNow instance.
Look for the relationship type that represents the containment or hosting relationship between "cmdb_ci_netapp_datacenter" and "cmdb_ci_netapp_svm" CIs.
Take note of the sys_id of the relationship type and the target class sys_id.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 09:22 AM
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?