Can you use an API to pull data from a CMDB Query builder query?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2019 09:58 PM
We would like to extract relationship data from the CMDB using an API. The best way I can think of is to create a query using the CMDB query builder and if possible run the query using an API. I have searched and can find no information on whether this is possible.
- Labels:
-
Customer Success
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2019 10:54 PM
Yes, you can use table apis in case you want to know attributes of a specific CI,
https://docs.servicenow.com/integrate/inbound_rest/concept/c_TableAPI.html
In case you need to find the relationships , it becomes little tricky but you can query cmdb_rel_ci and find the right CI.
Also, you can use Identification and Reconciliation APIs to fetch the data through REST,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2019 11:10 PM
Thanks Jayant, reconstructing the query by using the cmdb_rel_ci table is too complex and hence this is one of the reason ServiceNow has introduced the Query Builder. Having said that, I think you might be onto something as i think the query builder outputs to tables that we could possibly use
https://docs.servicenow.com/integrate/inbound_rest/concept/c_TableAPI.html
I am not sure how the last option would help and would need to explore that.
Thanks again for your reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 08:13 PM
I just started looking into doing the same. Were you able to accomplish this? (retrieving data from a saved query using the API)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 11:25 PM
There is an API that will generate a temporary table of results, and provide a JSON object on how to access the report.
Please see the CMDBQueryBuilderAPI documentation:
Attached is an example:
var result = SNC.CMDBQueryBuilderAPI.getSavedQueryExecutionDetails("QueryBuilderReportName", true);
gs.info(result);
// var result =
// { "execution_batch_size":100,
// "query_id":"aabb556671baabb506d66777fdc4142321",
// "table_name":"u_cmdb_qb_result_791ccddeeff7a168bb1122334455688778899ab143aabb666",
// "status":"COMPLETE"
// }
The report data can be accessed from the "table_name" property of the JSON object and will be stored in the following table:
u_cmdb_qb_result_791ccddeeff7a168bb1122334455688778899ab143aabb666
Thanks,
~CK