We’ve extended Inspire Early Bird Pricing until March 1. Register now and enjoy 20% off conference passes and 10% off training passes. P.S. Don’t forget to bring friends! When you sign up for five or more tickets, you get an extra 20% discount on conference passes. Learn more now.

Alteryx Designer Desktop Discussions

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

Loop until state has value of "Fulfilled" - API call to iterate until value is reached

Archaeopteryx
10 - Fireball

I run APIs against a cloud platform daily that extracts many Megabytes of information. To set this up, I first run a request for a job ID. The request body json I give this request is a date range only.

 

The API payload returns a Job ID.

 

The Job ID is like an Order number, think of it that way. The Order ( Job ID ) takes time to fulfill. It could take 20 seconds to 2 or 3 hours. 

 

I run an API that checks the state of that Job ID ( Order number ). When I get a state of "Fulfilled", then, I can run another API using that Job ID to extract the data. The data will not be ready to extract until I get that state of "Fulfilled".

 

I'm asking for assistance to iterate that API call for state until it has reached a value of "Fulfilled". Then, I go on to process the next API call.

 

I have a workflow that does the rest very well. But if I do not iterate that request for state API, but instead run it inline with the workflow, I may not get any data as the Job ID ( Order number ) is not ready. 

 

Thank you for any assistance.

Chris

 

 

7 REPLIES 7
rafalolbert
ACE Emeritus
ACE Emeritus

Hi @Archaeopteryx,

 

I came across a similar use case when working with Adobe Analytics API a few years back.

 

This required the initial authentication handshake, followed by issuing a report request and the final step was the download of data, but as with your case, the pre-requisite was the pro-active confirmation of the report results.

 

The best way forward for this type of use case is an iterative macro, where you'll need to iterate until the report is ready.

 

A great video on iterative macros is available here: https://community.alteryx.com/t5/Videos/Build-Your-First-Iterative-Macro/td-p/55565

 

This is quite narrow use case and it would be hard for me to build something for you without further context, but the above resource should give you a very good idea.

 

Iterative macros are not super straightforward at first look, don't get discouraged...when you clock on the use case in the video, I'm sure you'll be able to translate to your problem. Key watch-outs are:

 

- formulate iteration step and evaluate with a FIlter for when this condition is met and iteration should stop vs. when to continue

- go into Interface Designer to setup iteration input and output and max number of iterations (this is to prevent infinite loop)

- indicate the iterative macro type in workflow configuration (this is the only macro type that needs an explicit indication of type)

 

Hope this helps, let me know how you get on?

 

Thanks,

Rafal

 

#Excuse me, do you speak Alteryx? 

 

 

 

Archaeopteryx
10 - Fireball

Rafal,

Thank you for the explanation of the iterative macro. I will study the video you have provided. I'm sure it's very straightforward, but, you know, the getting started part.... 

 

Yes as you have indicated, there is an authentication part, which I have coded. Now, get the JobID then wait until that "order" ( JobID ) is ready to process by pinging for its availability status. Getting that part down will help me to fully automate this process. 

 

Thanks again for the explanation of the iterative macro, I'll review the video and I'll let you know how things progress. 

 

Chris

Archaeopteryx
10 - Fireball

Rafal

 

I run into confusion when carrying data entering and exiting the macro. Data I carry into the macro will not also leave the macro when re-entering the workflow. So I have red ink for a field that can no longer be found. 

 

What data should enter an iterative macro, and conversely, what data can I expect to have retained once I leave the macro and re-enter the workflow??

 

 

rafalolbert
ACE Emeritus
ACE Emeritus

Hi @Archaeopteryx,

 

Great, you're trying to implement using an iterative macro approach!

 

I'm thinking your logic should contain these 3x parts:

 

1) authentication & report request (normal workflow)

2) report availability check (iterative macro)

3) report download (normal workflow)

 

For #2 you should consider bringing in all authentication elements + report id that, I presume you should get upon completion of #1. 

The iterative macro should complete when the report availability status is positive and you shouldn't require any data to be enhanced between iterations, you can consider retaining iteration number/step. The whole solution could sit in one master workflow with iterative macro being the middle part.

 

Thanks,

Rafal

 

Archaeopteryx
10 - Fireball

So I pass the JobID to the macro from the main workflow - (1). The macro runs the 'state' API - (2). When the API returns "FULFILLED" then we move out of the macro and back into the workflow - (3). Thing is, I have to pass that JobID back to the main workflow (3) when we get that "FULFILLED" state. Nothing passes out of the macro is my experience. 

rafalolbert
ACE Emeritus
ACE Emeritus

Hi @Archaeopteryx,

 

You should be able to pass the JobID in and out of the iterative macro, but an easier way would be to use Append Fields Tool and bring it again after the iteration logic, would this work for you?

 

Thanks,

Rafal

Archaeopteryx
10 - Fireball

It seems the macro's template input 'must' include every input field that is introduced at the beginning of the workflow in order to continue passing it all along to the remainder of the workflow after the macro has processed. 

 

The two outlets on the macro, leaving one unusable, has the appearance of looking like a mistake or like something unfinished. Much like the filter tool when you have the 'false' outlet and do not really need it for anything. 

 

Thank you Rafal for your assistance and explanation. I think I have it working now. 

Chris

Labels