Hi Frank,
Here is an example how to use it:
@staticmethod
def _page_incidents(rest_client):
query = {
'start': 0,
'length': FeedComponent.INC_PAGE_SIZE,
'sorts': [
{
'field_name': 'id',
'type': 'asc'
}
]
}
url = '/incidents/query_paged?return_level=normal'
paged_results = rest_client.post(url, query)
while paged_results.get('data'):
data = paged_results.get('data')
for result in data:
yield result
query['start'] = len(data) + query['start']
paged_results = rest_client.post(url, query)
That method will "yield" results so it can be used like this:
try:
for incident in self._page_incidents(rest_client):
inc_id = incident['id']
...
except StopIteration:
pass
Hope this helps,
Tamara
------------------------------
Tamara Zlender
------------------------------
Original Message:
Sent: Fri May 10, 2019 10:31 AM
From: Frank Urbanski
Subject: Incident - query_paged
Hello all,
I am attempted to use /orgs/{org_id}/incidents/query_paged to pull back most, if not all, of my incidents to that I can work with the JSON data for custom reporting. Does anyone have an example of how to use this properly?
url = '/incidents/query_paged?return_level=normal'
filter = {"filters":[{"conditions":[{"field_name":"resolution_id","method":"in","value":[xxx,xxx,xxx,xxx]},{"field_name":"inc_training","method":"equals","value": False}]}]}
incidents = client.post(url, filter)
When I try this I still only get a max of 1000 results. I assume I'm doing something wrong.
Thanks in advance!
------------------------------
Frank Urbanski
------------------------------