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

Henrik Jutterst
Tera Guru

Still looking for an answer to this... Anyone with feedback?

As I explained above the request body must have

"object_id": "test",
         "volume_id":"test"

Please add those to request body and try.

I was able to create in my instance without any issue by passing values to object and volume id's

Did you get a change to test it using object and volume ids

Here's the feedback.

Please try the code your-self, but this does not solve the issue..

body:

{
	"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": [
		{"rel_type" : "55c95bf6c0a8010e0118ec7056ebc54d", "target": "007d9d0cdb6a63401c19b6bffe96194c"}],
	"outbound_relations": [
		{"rel_type" : "5599a965c0a8010e00da3b58b113d70e", "target": "85a0df05db8be3408956f3d61d961921"}
	]
}

 

Respons:

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

I thought your earlier requirement was without relations. If it is then try the below request body

 

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