โ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 12:25 PM
I tried constructing the URL in the mapper snap next to REST snap and got the Dynamic URL as $original.original.urlโฆ I also tried using the actual URL (without using any variables, just plain URL as โhttps://example-api.com/transactions?datemin=โฆโ
Both failed to fetch data from subsequent pages except the first page. The API for the given input parameters fetches close to 2000 records. i tried setting the page size to 10, 50, 100 and 200. But in all the cases, its fetching the data from the first page for whatever the size i set and comes out and finishes the process.
โ12-17-2018 12:53 PM
Here is the output structure
{
โPageNoโ: 5,
โPageSizeโ: 200,
โItemsโ: [
{
โTransactionIdโ: 000000,
โReceiptNoโ: 000,
โTerminalNameโ: โxxxxxโ,
โTerminalNoโ: 00000,
โDateโ: โ2018-12-16T18:07:03โ,
โTaxTotalโ: 999,
โTransactionItemsโ: [
{
โItemIDโ: 999,
โProductIDโ: 999,
โQuantityโ: 1,
โTotalโ: 5,
โTotalGrossโ: 4.55,
โTotalTaxโ: 0.45
}
],
โOrderTypeIDโ: 0
}
โ01-10-2019 12:31 PM
Thanks Alan for helping me solve the issue. I really appreciate you taking time to help me solve this.
โ06-16-2020 09:42 AM
This is interesting, but how is it useful if you need to write the results of a REST call out using another Snap?
โ06-16-2020 06:10 PM
The REST Get snap will output documents, which downstream you could write out to a database, another web service, etcโฆ Could you talk more about what youโre trying to do?