Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Iterative API download not ending after end condition met.

mathias149
5 - Atom

 

The iterative macro below pulls data down from Coupa's API until the payload back from Coupa is empty "= [] " I have tested this conditional outside of the macro and it works, but when I run in the macro it doesn't exit until the max iterations is hit. Attached the macro below.

 

* attached does have my api access token, but is just for the test site, and also for good measure I changed shortly after posting this (before someone tells me its bad practice to post that).

 

Would really appreciate a second set of eyes, thanks!

 

Untitled.png

5 REPLIES 5
Felipe_Ribeir0
16 - Nebula

Hi @mathias149 

 

What is the iteration parameter here? If i understood well you didnt set it up. The requested offset/range of records must increase between iterations.

 

Here i did something similar, using the page number = page number + 1 to iterate between pages of the SurveyGizmo API, if you want to check out:

 

https://community.alteryx.com/t5/Community-Gallery/SurveyGizmo-Alchemer-API-GET-survey-data/ta-p/999...

 

Felipe_Ribeir0_0-1670428980083.png

 

 

 

mathias149
5 - Atom

It uses the [Engine.IterationNumber] variable to increase the offset in the API call. And it works, I am getting all the records I should be getting. The problem is the exit condition conditional is not stopping the loop when the data returned is empty (implying that I had reached the end of the records)

 

'https://nuskin-test.coupahost.com/api/contracts?fields=["id"]&offset='+tostring([Engine.IterationNumber]*50)

Felipe_Ribeir0
16 - Nebula

@mathias149 

 

Ok, so if you replicate this idea it will work

 

1-When download data is null, [] or what it is after the last iteration, fiter it

2-Append this table with null rows (and sample = 1) to the next page parameter (so it wont exist)

 

Felipe_Ribeir0_0-1670429373302.png

 

mathias149
5 - Atom

@Felipe_Ribeir0 thanks sir. I'll give that a shot. I like to understand what I am doing wrong, can you help me understand why my approach didn't work, Still not quite understanding that bit.

Felipe_Ribeir0
16 - Nebula

@mathias149  Your iterations wont stop until you have this on your iteration loop.

 

Felipe_Ribeir0_0-1670431875145.png

 

It seems that your current workflow continue to provide the URL`s even after the last available data.

Labels