The CreatorCon Call for Content is officially open! Get started here.

Can't insert cmdb_ci_storage_volume CI via CMDB Instance API

Henrik Jutterst
Tera Guru

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.

1 ACCEPTED SOLUTION

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"
			
		}
	}
}

 

find_real_file.png

Part of response

find_real_file.png

 

View solution in original post

27 REPLIES 27

dvp
Mega Sage

CMDB API goes by CI Identifiers

Navigate to

Configuration > Identification/Reconciliation> CI Identifiers

and search for Storage Volume Rule

As object_id and volume_id are specified as identifier entries you must pass those values in the request body

Here is an example for request body

{
    "attributes":
    {
        "name": "heju-test-2019018-00l1",
        "object_id": "test",
         "volume_id":"test"
    },
"source": "ServiceNow"

}

I'm sorry to say, but that does not solve the issue. The code submitted does not work on this API. 😞

As I said in the description, I can add a CI by clicking New-button when listing CI's in the table, but using the API does not work.

 

{
  "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\":{\"discovery_source\":\"ServiceNow\",\"volume_id\":\"test\",\"name\":\"heju-test-2019018-00l1\",\"object_id\":\"test\"}}'"
          },
          {
            "error": "ABANDONED",
            "message": "Too many other errors"
          }
        ],
        "identificationAttempts": []
      }
    ],
    "relations": [],
    "logContextId": "97d7c7b1db132300fbe3bd51399619c2"
  }
}

Can you share the request body