- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2015 05:10 AM
I have few questions, It would be great if someone could answer them.
- How to fetch the incidents sorted by time?
- One REST API query returns approx. 501 Incidents. How to get the next set of incidents? [required for pagination]
- REST API to create/update/delete/view Knowledge ? Any Documentation?
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2015 08:33 AM
Hi Sanjay,
For pagination, you can make use of the sysparm_offset and sysparm_limit parameters.
For example the following will retrieve 5 records (sysparm_limit=5) in the record set starting from the beginning (sysparm_offset=0) of the record set.
/api/now/v1/table/incident?sysparm_limit=5&sysparm_offset=0&sysparm_query=active=true^ORDERBYnumber
The get the next 5 records, you would simply increment the value of sysparm_offset by the value of your sysparm_limit
/api/now/v1/table/incident?sysparm_limit=5&sysparm_offset=5&sysparm_query=active=true^ORDERBYnumber
Another thing that helps is that you will actually get a link header in the response that provides the urls to first,prev,next and last pages based on values used for sysparm_offset and sysparm_limit. so you might just look into that to get the url to use to get the next page.
Hope this helps!
-Jose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2015 05:23 AM
REST API Explorer - ServiceNow Wiki
fetch from where to where?
Inside of ServiceNow RESTMessage you will find HTTP Methods ... "get", for example .. drill down into it preferences and click "Preview Script Usage" ... so you may use script ordering of data you receive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2015 06:25 AM
Hi Sanjay,
With regards to your Query 1.
You can use a encoded query copied from a list view.
http://wiki.servicenow.com/index.php?title=Table_API
..
4 Methods
4.1 GET /api/now/v1/table/(tableName)
This method retrieves multiple records for the specified table with proper pagination information.
Supported Parameters
Parameter | Description |
---|---|
sysparm_query | An encoded query. For example: (sysparm_query=active=true)(sysparm_query=caller_id=javascript:gs.getUserID()^active=true) Note: The encoded query provides support for order by. To sort responses based on certain fields, use the ORDERBY and ORDERBYDESC clauses in sysparm_query. For example, sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory filters all active records and orders the results in ascending order by number first, and then in descending order by category. |
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2015 02:45 AM
Thanks Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2015 08:33 AM
Hi Sanjay,
For pagination, you can make use of the sysparm_offset and sysparm_limit parameters.
For example the following will retrieve 5 records (sysparm_limit=5) in the record set starting from the beginning (sysparm_offset=0) of the record set.
/api/now/v1/table/incident?sysparm_limit=5&sysparm_offset=0&sysparm_query=active=true^ORDERBYnumber
The get the next 5 records, you would simply increment the value of sysparm_offset by the value of your sysparm_limit
/api/now/v1/table/incident?sysparm_limit=5&sysparm_offset=5&sysparm_query=active=true^ORDERBYnumber
Another thing that helps is that you will actually get a link header in the response that provides the urls to first,prev,next and last pages based on values used for sysparm_offset and sysparm_limit. so you might just look into that to get the url to use to get the next page.
Hope this helps!
-Jose