CMDB and REST API

davidbaileyritn
Kilo Contributor

I am using the REST API to get details of a CI instance :

Example https://dev20622.service-now.com/api/now/cmdb/instance/cmdb_ci_appl/82992eb60ad337024fbb6d06a866c636

 

In the response received I can see the link to the Maintenance Schedule for the CI, but when I query the Maintenance Schedule, I cannot seem to extract the start and end dates of the schedule. Can you please let me know how to go about getting all Maintenance windows associated with a CI using REST API?

 

Thanks

1 ACCEPTED SOLUTION

Rahul Priyadars
Tera Sage
Tera Sage

Hi ,

I see in Table cmn_schedule_span Two Fields:

Name:- Actual Name of Schedule Window 

Schedule- Name of Maintenance Schedule (Stored In this Table-cmn_schedule_maintenance)

Now Store the Name of Maintenance Schedule  and do lookup in Table cmn_schedule_span based on this value.

You will get the name of Schedule Window and from here you can fetch the data for Start and End Date.

Attaching Screen shot for More Clarity.

find_real_file.png

Regards

RP

View solution in original post

9 REPLIES 9

davidbaileyritn
Kilo Contributor

Thank you for the quick response again, Rahul!

I tried looking at the cmn_schedule_span table. Like you said it has all the necessary information that I need, like the maintenance schedule entries. 

Querying this table with the sys_id of the schedule though, returns nothing. So I tried other parameters like querying the cmn_schedule_span table with the name of the schedule, but again it returns nothing.

Would you know of a way to query the entries with the Schedule SysId or Schedule Name as these are the only two bits of information that I have to query the maintenance entries

Thanks

Rahul Priyadars
Tera Sage
Tera Sage

Hi ,

I see in Table cmn_schedule_span Two Fields:

Name:- Actual Name of Schedule Window 

Schedule- Name of Maintenance Schedule (Stored In this Table-cmn_schedule_maintenance)

Now Store the Name of Maintenance Schedule  and do lookup in Table cmn_schedule_span based on this value.

You will get the name of Schedule Window and from here you can fetch the data for Start and End Date.

Attaching Screen shot for More Clarity.

find_real_file.png

Regards

RP

Thank you RP for the response. Yes, this works perfectly from the UI and I can see all the schedule span entries linked to the schedule and can create a filter for to query the schedule spans by maintenance schedule name.

But when I access the same information via REST API, I get empty rows unfortunately.

https://<SN Instance>/api/now/table/cmn_schedule_span?sysparm_fields=schedule.name=Application+FLX

The above url queries the "cmn_schedule_span" table for schedules with name "Application FLX" and my response comes up as empty 

<response>
<result/>
<result/>
<result/>
<result/>
<result/>
<result/>
<result/>
<result/>
<result/>
</response>
 
I also tried querying the cmn_schedule_span table with the schedule sys_id, but its the same result
 
https://<SN>/api/now/table/cmn_schedule_span?sysparm_fields=schedule.sys_id=82b90aa00ad337027ef3faa2690f25a8
 
Any inputs on the REST API querying for this?
 
Kind Regards
 

Hi,

 

I got it to work, the following API query worked well:

 

https://<SN>/api/now/table/cmn_schedule_span?sysparm_query=schedule.sys_id=04e664654a36232701a2247dcd8fc4cf

 

Thank you for your time & support!

 

Kind Regards

 

 

Rahul Priyadars
Tera Sage
Tera Sage

Good That It worked Now. Please close the thread .

Regards

RP