The CreatorCon Call for Content is officially open! Get started here.

Stuck in rest api date formula

s_gatade
Kilo Contributor

All,

To start with, I'm not sure if this is right forum to post my question!

I'm experimenting with Service NOW REST API and am stuck in a situation where I need to GET incidents created ON and/or AFTER a certain date. I'm not sure how to form the REST URL since normal ways of LESS THAN or GREATER THAN with proper date format are not working.

The following URL gives me the correct incident registered on the particular date i.e. opened_at=2013-04-18+06:37:37

https://xxxxxxxx.service-now.com/api/now/v1/table/incident?priority=3&sysparm_limit=10&sysparm_field...

But I need to get ALL the incidents OPENED AFTER this date... I've tries &gt, %3E%3D, >= and all combinations but am getting "No record found" message.

I've searched High & Low on ServiceNOW Wiki & other forums but no lead till now...

Please do let me know how this can be done...

Thanks in advance...

S. Gatade

1 ACCEPTED SOLUTION

Mike Allen
Mega Sage

When I use the REST API Explorer, it shows me this:



var request = new sn_ws.RESTMessageV2(); request.setEndpoint('https://dev14066.service-now.com/api/now/table/incident?sysparm_query=sys_created_on%3E%3Djavascript%3Ags.dateGenerate('2015-12-09'%2C'14%3A05%3A30')&sysparm_limit=10'); request.setHttpMethod('GET'); 


Capture.PNG



Capture.PNG


View solution in original post

5 REPLIES 5

You have to ASCII Encode it HTML URL Encoding Reference




https://<server instance/api/now/table/cmdb_rel_ci?sysparm_limit=10&sysparm_query=active%3Dtrue%5Esys_updated_on%3Ejavascript%3Ags.daysAgoEnd%28100%29