REST API getting last modified item from Incidents table

oijsaljsa
Kilo Contributor

Does anyone know is it possible and if so than how to achieve that to get latest modified incident using REST API.

I'm able to get specific users incident (limited to 1 record), but I'd like to always get the latest modified one.

Any ideas appreciated.

1 ACCEPTED SOLUTION

josh_nerius
ServiceNow Employee
ServiceNow Employee

Hi Pawel,



You can use an encoded query to control the order of records returned by the API. Try this:



https://yourinstance.service-now.com/api/now/table/incident?sysparm_limit=1&sysparm_query=ORDERBYDESCsys_updated_on



This will give you the last modified incident, but you can refine the query further by adding additional clauses to the query.



For more information, take a look at the sysparm_query documentation here: https://developer.servicenow.com/app.do#!/rest_api_doc?v=istanbul&id=r_TableAPI-GET


View solution in original post

1 REPLY 1

josh_nerius
ServiceNow Employee
ServiceNow Employee

Hi Pawel,



You can use an encoded query to control the order of records returned by the API. Try this:



https://yourinstance.service-now.com/api/now/table/incident?sysparm_limit=1&sysparm_query=ORDERBYDESCsys_updated_on



This will give you the last modified incident, but you can refine the query further by adding additional clauses to the query.



For more information, take a look at the sysparm_query documentation here: https://developer.servicenow.com/app.do#!/rest_api_doc?v=istanbul&id=r_TableAPI-GET