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

can you share the JSON output of this REST GET without pagination?

The best way to design โ€œhas nextโ€ and โ€œnext URLโ€ I found is to use a mapper after REST GET to come up with an expression that will give you true for โ€œhas nextโ€ and next page URL for โ€œnext URLโ€. Once you figure those out then just copy those expressions back to the REST GET configuration.

I am able to get the condition which returns true if data exists for โ€œHas nextโ€ which is โ€œjsonPath($, โ€œ$entity.Items[*]โ€).length > 0โ€.

The โ€œNext URLโ€ has the correct URL, but is not triggering the URL as it is loading only the data for the Page = 1. The basic URL has the key at the header level. Does the Next URL attribute need to also have the key mentioned?

Not for HTTP Header. Have you tried to place a static URL for page 2 and see if it works?

I tried the Next URL with static URL to fetch the page 2, but it is not loading after the Page 1 data.

which means your โ€œhas Nextโ€ is false.

Can you share the entire JSON output from โ€œDownloadโ€ from the output view?

28%20PM