hello
I am downloading json data using an api call i have built in alteryx. In the API call, i have to declare page size, which i am setting to 500, to get 500 records. then i need to add page index. for page index, i have tried iteration engine, that is, to add 1 to the page index with every iteration. However, i get only 500 records.
Iterative macros are a little tricky to configure, so if possible, i personally like to avoid them. This seems to be a case where you can avoid it.
1-I suppose that if you make one first call to the API, it will return the total number of pages inside of the response.
2-Knowing the total number of pages, you can use the Generate Rows tool to generate 1 only row of url/parameters for each API call, and then the download tool can deal iteratively with each one of them.
Hope this is useful, debug iterative macros is boring.
sorry, this api url does not show us total number of pages. we will do error check on response, if it errors out, then break out of iteration.
i can use the generate rows. the only check we will have is when items len is 0 that means no more data on remaining pages.
see below. If i put 100 pageindex, it will keep checking each page to see if any data exists.
How can i break out of this loop when index 4, no more data exists?
any help will be appreciated
This problem is solved inside of this macro, and i believe that you can adapt the idea to your case: https://community.alteryx.com/t5/Community-Gallery/SurveyGizmo-Alchemer-API-GET-survey-data/ta-p/999...
Basically, there is a filter that see if the JSON response contains a specific value (for this case, "data."). If it do not, then we know that the macro needs to stop, and the append tool will not let the next iteration happen.