12-12-2018 07:36 AM
Hello,
I am trying to load transaction data from a REST API end point. The API has pagination as required Input parameter. I am using the REST GET to fetch the data and the Https URL should be as below.
https://xxxxxx–xxx/transactions?datestart=2018-11-19T00:00:00&dateend=2018-11-20T00:00:00&pageSize=1000&pageNo=1.
I am trying to design a process which loops thru till the REST API call returns null data set.
For example, if the above REST URL gives output, I have to call the same URL again with the pageNo input parameter as 2 and if it provides a data set, then 3 and on and on. The loop has to end when the REST API comes out with a null data.
Any help to solve this would be highly appreciated and also would like to know if looping is the only option and right approach.
Thanks
Aravind N
12-18-2018 10:54 AM
I have the JSON output attached.
REST_GET For Task Transactions.zip (2.7 KB)
12-18-2018 11:26 AM
here should be your hasNext expression, assuming each page return maximum of 10 records. There also doesn’t seem to be any other data from your output which indicate if there is a next page. So, all we can do is to check if result has the maximum number of records in return.
$entity.PageSize == 10
As for your next url
the page number should be “$entity.PageNo+1” insterad of “$original.pageno_1”
12-18-2018 11:48 AM
I tired the above solution in vain. I set hasNext = $entity.PageSize == 10
and set next url as both
$original.uri+“?datemin=”+$original.datemin+“&datemax=”+$original.datemax+“&pagingArgs.pageSize=”+$original.pagesize+“&pagingArgs.pageNo=”+($entity.PageNo+1)
and also tried using
$original.uri+“?datemin=”+$original.datemin+“&datemax=”+$original.datemax+“&pagingArgs.pageSize=”+$original.pagesize+“&pagingArgs.pageNo=”+($original.pageno+1)
Its only loading the first page and not pulling result from subsequent pages.
12-18-2018 11:49 AM
12-18-2018 12:12 PM
You need to follow my suggestion to construct your next URL by using a mapper after your rest get. All those $original.xxxxxx isn’t matching in your provided JSON. E.g. original.url should be original.original.url