โ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