cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to loop thru a REST snap

arvindnsn
Contributor

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

26 REPLIES 26

I have the JSON output attached.

REST_GET For Task Transactions.zip (2.7 KB)

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โ€

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.

image

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