How do I use REST APIs to list related entities in CMDB? e.g. I would like to list all databases running on a given linux server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2019 09:50 AM
How do I use REST APIs to list related entities in CMDB? e.g. I would like to list all databases running on a given linux server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2019 11:35 AM
If you were logged into your ServiceNow Instance, you would be able to create such a query using the CMDB Query Builder.
Since you want to use REST APIs, you will need to make several calls. You first need to query the Linux server table for the sys_id of your Linux server.
First, you do a GET to:
https://<instance>.service-now.com/api/now/table/cmdb_ci_linux_server?sysparm_query=name%<name_of_your_linux_server>
This would return all your Linux Servers, you need to get the specific Linux Server you are interested in and get the sys_id of that server. Then you need to query the cmdb_rel_ci table for the list of runson relationships where your linux server is a child
https://<instance>.service-now.com/api/now/table/cmdb_rel_ci?sysparm_query=child%<sys_id_of_linux_server>
That would return all the parent/child relationships and you would look for the parent field. That's a list of parent CIs and the databases running on that Linux server would be in that list.
cmdb_ci_appl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2019 04:36 PM
Thanks. Feels like lot of post processing. Wish there were queries that can retrieve to relationships by name and an instance name

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2019 03:27 AM
Try this one. Tested it on one of our instances with demo-data but it basicly just adds a query to the relationship table and searches for records where the parent.class is mssql-instance (you can add whatever class you like ofc) and where the child.name matches what we are looking for which in this case would be the server running the MSSQL database instance. So this way you can query the relationship table (or any other table) by using dotwalking in the query. I also added some sysparm_fields just the filter the data I get back.
https://instancename.service-now.com/api/now/table/cmdb_rel_ci?sysparm_query=parent.sys_class_name%3Dcmdb_ci_db_mssql_instance%5Echild.name%3DV-WIN-SQL01&sysparm_fields=parent.name%2Cchild.name%2Ctype.name%2Cchild.sys_class_name%2Cparent.sys_class_name%2Cparent.sys_id%2Cchild.sys_id