REST error, MISSING_DEPENDENCY

Henrik Jutterst
Tera Guru

I need some input on how to resolve an issue I have when I would like to add a CI via REST API.

I'm kind of new to REST API, and I don't know how to resolve this issue or where to see what is supposed to be submitted in my payload. (I'm using Postman for this purpose)

 

POST https://instance-name.service-now.com/api/now/cmdb/instance/cmdb_ci_storage_volume

{
    "attributes": {
    "name": "heju-test-20190121-001",
    "fqdn": "heju-test-20190121-001",
    "company": "d9efdcacdb4a620076fabc2ffe9619a8",
    "location": "6b059335dbd18f0076fabc2ffe9619c9",
    "storage_type": "LUUN",
    "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",
    
    "disk_space": "4000",
    "type": "Runs on::Runs",
    "child": "0"
  },
  "source": "ServiceNow"
}

 

Response:

{
    "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\":\"LUUN\",\"short_description\":\"Here's a newly created CI created from ServiceNow API\",\"fqdn\":\"heju-test-20190121-001\",\"ip_address\":\"10.14.121.124\",\"last_discovered\":\"2019-01-21 08:33:29\",\"disk_space\":\"4000\",\"type\":\"Runs on::Runs\",\"discovery_source\":\"ServiceNow\",\"name\":\"heju-test-20190121-001\",\"dns_domain\":\"blank-heju\",\"company\":\"d9efdcacdb4a620076fabc2ffe9619a8\",\"location\":\"6b059335dbd18f0076fabc2ffe9619c9\",\"child\":\"0\"}}'"
                    },
                    {
                        "error": "ABANDONED",
                        "message": "Too many other errors"
                    }
                ],
                "identificationAttempts": []
            }
        ],
        "relations": [],
        "logContextId": "c565f183db0f6f408956f3d61d961979"
    }
}

 

find_real_file.png

1 ACCEPTED SOLUTION

Henrik Jutterst
Tera Guru
11 REPLIES 11

Henrik Jutterst
Tera Guru

Anyone here who can give me a hint on what's missing and what I can do to fix this using my main payload?

Thanks!

This seems to be an example, but I can't find an example of what the actual code would look like:

https://docs.servicenow.com/bundle/london-application-development/page/integrate/inbound-rest/concep...

 

Code:

{
	"attributes": 
	{
		"name": "heju-test-20190128-001",
		"fqdn": "heju-test-20190128-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",

		"disk_space": "4000"
	},
	"source": "",
	"inbound_relations": [
		{"rel_type" : "5599a965c0a8010e00da3b58b113d70e", "target": "85a0df05db8be3408956f3d61d961921"}
	]
}

 

 

Result:

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

charlieloza
Kilo Contributor

Hello,

 

Have you been able to resolve this?, if not, did you tried looking at the "Identification Simulation" module?,

its under Configuration > Identification/Reconciliation > Identification Simulation, it lets you generate the correct JSON structure with relations included, you can select a class and define example relationships

 

Hope this helps

Hi and a BIG thank you for this post! The question finally got solved in another thread, but this will come in handy many times in the future!!

Have a great day, and once a again - thank you very much!