- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 09:12 AM
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
But I need to get ALL the incidents OPENED AFTER this date... I've tries >, %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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 09:23 AM
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');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 09:23 AM
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');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 10:27 AM
Thanks a lot Mike! I even tried javascript args sometime back but was not getting the correct one. I did play around with your URL and its working, I'll do some more tests later...
Thanks again for the prompt and correct response!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 09:24 AM
Hi Shailendra,
You can create a query in a list view as required, copy it and use it as per wiki below:
http://wiki.servicenow.com/index.php?title=Table_API#Methods4.1 GET /api/now/v1/table/(tableName)
This method retrieves multiple records for the specified table with proper pagination information.
Supported Parameters
sysparm_query | An encoded query. For example: (sysparm_query=active=true)(sysparm_query=caller_id=javascript:gs.getUserID()^active=true) |
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2016 08:07 PM
I'm having issues getting the Date filter to work with the table api
Example I've tried all return 20 rows without ANY filtering using Postman (I have older date than I want)
https://<MyInstance>/api/now/table/cmdb_rel_ci?sysparm_query=sys_update_on>'2015-01-01%3223:59::59'&sysparm_limit=20&sysparm_offset=0
https://<MyInstance>/api/now/table/cmdb_rel_ci?sysparm_query=sys_update_on>=javascript:gs.dateGenerate('2015-01-01','00:00')&sysparm_limit=20&sysparm_offset=0