How to get the incident history using REST API

vishisag
Kilo Explorer

I am trying to get the changes of a particular incident that had happened on a particular date from service now incident. I am passing date and the incident number as the query parameter. Is there any REST API that I can use to get it. Or is there any way to get it. I am not looking forward to using SOAP. Thanks in advance.

4 REPLIES 4

srinivasthelu
Tera Guru

Hi Vishi,



Below are the table APIs for History record and History Line item



https://[InstanceName].service-now.com/api/now/table/sys_history_set



https://cert032.service-now.com/api/now/table/sys_history_line



History Line Item stores the updates for the each field in each record.



Screen Shot 2016-02-11 at 8.22.06 PM.png




History Set table links the incident record and line items.



You can explore more on right clicking the form header and show history



Thanks


Srini


I get the error 403 (forbidden).


Kyryl Petruk1
Tera Expert

If you are interested in a specific kind of change, e.g. change of the incident state - you can configure a metric and then query metric_instance table


justin_tuma
Giga Contributor

I had this same issue and, elaborate on Srinivas' post above, here's what I did.   In order to pull the history for a task, you can pass the sys_id for that task and match it up with the id field of the sys_history_set table.



Here's a basic example - you just need to substitute the sys_id of your incident:



https://<instance>.service-now.com/api/now/table/sys_history_line?sysparm_query=set.id=<sys_id_of_ta...>



And a little more complicated example pulling specific fields and filtering out original values (what update!=0 does).   Hope this helps!



https://<instance>.service-now.com/api/now/table/sys_history_line?sysparm_query=fieldINduration,star...