
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 12:36 PM
Trying to figure out Why I can insert a new from the GUI into cmdb_ci_storage_volume table without any relations, but when I try to do the same via API (see this thread https://community.servicenow.com/community?id=community_question&sys_id=20c5ed1ddbd7a3c0fa192183ca96...) I have to add relations.
Why is that so?
I want to use this CMDB API to get all functions and checks for input data and not just use table API.
Using Kingston at the moment.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 01:38 AM
I see there are some typos in the request body that you had tried earlier. Here is the one that is working for me in REST Client
Please use the following body and try again and also make sure that type and target sys_id's are valid
{
"attributes":
{
"name": "heju-test-20190204-008",
"fqdn": "heju-test-20190204-008",
"company": "d9efdcacdb4a620076fabc2ffe9619a8",
"location":"6b059335dbd18f0076fabc2ffe9619c9",
"storage_type": "LUN",
"last_discovered": "2019-01-21 08:33:29",
"short_description": "Here's a newly created storate volume ci related to computer Child created from ServiceNow API outbound - 8",
"object_id": "test2",
"volume_id":"test2",
"dns_domain": "blank-heju",
"ip_address": "10.14.121.124"
},
"source": "ServiceNow",
"depends_on":{
"inbound_relations" :
{ "type": "55c95bf6c0a8010e0118ec7056ebc54d",
"target":"00e0fc12db062f001c19b6bffe961931",
"sys_class_name": "cmdb_ci_computer"
}
}
}
Part of response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 04:40 AM
Here's the result of above code:
{
"result": {
"items": [
{
"sysId": "Unknown",
"identifierEntrySysId": "Unknown",
"errors": [
{
"error": "MISSING_DEPENDENCY",
"message": "In payload no relations defined for dependent class [cmdb_ci_storage_volume] that matches any containment/hosting rules: [cmdb_ci_storage_volume >> Contained by >> cmdb_ci_computer,cmdb_ci_storage_volume >> Owned by >> cmdb_ci_storage_cluster,cmdb_ci_storage_volume >> Hosted on >> cmdb_ci_logical_datacenter]. Add appropriate relations in payload for '{\"className\":\"cmdb_ci_storage_volume\",\"values\":{\"storage_type\":\"LUN\",\"short_description\":\"Here's a newly created CI created from ServiceNow API\",\"discovery_source\":\"ServiceNow\",\"volume_id\":\"test\",\"fqdn\":\"heju-test-20190204-001\",\"name\":\"heju-test-20190204-001\",\"dns_domain\":\"blank-heju\",\"company\":\"d9efdcacdb4a620076fabc2ffe9619a8\",\"ip_address\":\"10.14.121.124\",\"last_discovered\":\"2019-01-21 08:33:29\",\"disk_space\":\"4000\",\"object_id\":\"test\"}}'"
},
{
"error": "ABANDONED",
"message": "Too many other errors"
}
],
"identificationAttempts": []
}
],
"relations": [],
"logContextId": "d569ada3db13e7c08956f3d61d9619d5"
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 04:52 AM
I used same body and it ran without any issues.
{
"result": {
"outbound_relations": [],
"attributes": {
"storage_type": "LUN",
"skip_sync": "false",
"operational_status": "1",
"lun": "",
"sharable": "false",
"sys_updated_on": "2019-02-04 12:43:37",
"discovery_source": "ServiceNow",
"first_discovered": "2019-01-29 21:13:52",
"sys_updated_by": "admin",
"due_in": "",
"media_type": "",
"sys_created_on": "2019-01-29 21:13:52",
"sys_domain": {
"display_value": "global",
"link": "https://dev10245.service-now.com/api/now/table/sys_user_group/global",
"value": "global"
},
"install_date": "",
"state": "",
"invoice_number": "",
"gl_account": "",
"sys_created_by": "admin",
"warranty_expiration": "",
"asset_tag": "",
"fqdn": "heju-test-20190204-001",
"change_control": "",
"vdisk_id": "",
"owned_by": "",
"checked_out": "",
"sys_domain_path": "/",
"disk_space": "4000",
"object_id": "test",
"maintenance_schedule": "",
"delivery_date": "",
"install_status": "1",
"size": "",
"cost_center": "",
"supported_by": "",
"dns_domain": "blank-heju",
"name": "heju-test-20190204-001",
"provided_by": "",
"assigned": "",
"delete_on_termination": "false",
"purchase_date": "",
"subcategory": "",
"device": "",
"short_description": "Here's a newly created CI created from ServiceNow API",
"size_bytes": "",
"volume_id": "test",
"assignment_group": "",
"managed_by": "",
"last_discovered": "2019-01-21 08:33:29",
"can_print": "false",
"sys_class_name": "cmdb_ci_storage_volume",
"manufacturer": "",
"mapping_type": "",
"sys_id": "2e95a8f90f5b6700e1f30dbce1050e14",
"file_system": "",
"po_number": "",
"computer": "",
"sys_class_path": "/!!/#8",
"checked_in": "",
"vendor": "",
"mac_address": "",
"company": {
"display_value": "",
"link": "https://dev10245.service-now.com/api/now/table/core_company/d9efdcacdb4a620076fabc2ffe9619a8",
"value": "d9efdcacdb4a620076fabc2ffe9619a8"
},
"model_number": "",
"justification": "",
"department": "",
"assigned_to": "",
"start_date": "",
"cost": "",
"comments": "",
"sys_mod_count": "1",
"serial_number": "",
"monitor": "false",
"label": "",
"model_id": "",
"ip_address": "10.14.121.124",
"sys_tags": "",
"volume_container": "",
"cost_cc": "USD",
"share_count": "",
"support_group": "",
"schedule": "",
"order_date": "",
"protected_by": "",
"due": "",
"correlation_id": "",
"unverified": "false",
"attributes": "",
"location": "",
"asset": "",
"category": "",
"fault_count": "0",
"free_space": "",
"free_space_bytes": "",
"lease_id": ""
},
"inbound_relations": []
}
}
Let me try with relations..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 05:02 AM
Here is the format with inbound relations
{
"attributes":
{
"name": "heju-test-20190204-001",
"fqdn": "heju-test-20190204-001",
"company": "d9efdcacdb4a620076fabc2ffe9619a8",
"storage_type": "LUN",
"last_discovered": "2019-01-21 08:33:29",
"short_description": "Here's a newly created CI created from ServiceNow API",
"dns_domain": "blank-heju",
"ip_address": "10.14.121.124",
"object_id": "test",
"volume_id":"test",
"disk_space": "4000"
},
"source": "ServiceNow",
"inbound_relations": [
{
"type": "85d98503ff100200d699ffffffffff8c",
"target": "01a9ec0d3790200044e0bfc8bcbe5dc3",
"sys_class_name": "cmdb_ci_computer"
}
]
}
Note - Inbound relations are the ones where current CI (one that will be created in this example) appears as the child in the relationship (i.e. cmdb_rel_ci record). Outbound relations are the ones where current CI appears as the parent in the relationship (i.e. cmdb_rel_ci record).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 05:05 AM
Thanks for the help, but there seems to be an issue still 😕
I copied the code into postman and ran it:
{
"error": {
"detail": "Invalid relation entry with non-existent target sys id '01a9ec0d3790200044e0bfc8bcbe5dc3' provided in input",
"message": "Invalid Relation Entry"
},
"status": "failure"
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 05:29 AM
Looks like you are using target sys_id of mine. You need to use the target sys_id from your instance