Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Serial REST calls

jt7Princeton
6 - Meteoroid

Hello.  I am developing a new workflow that needs to call different endpoints of the same REST API.  Essentially I want to loop through each row URL, call and get the results, and save each in respective new tables that I plan to transfer to a SQL Server using indb functions

 

I started following the instructions here: https://community.alteryx.com/t5/Engine-Works-Blog/REST-API-In-5-Minutes-No-Coding/ba-p/8137 using the text input tool.  Is this the right way to go about it?  I understand how to use the download tool to call the first, but how would i loop to rows 2-*?

 

2019-05-02_12-50-05.png

9 REPLIES 9
Claje
14 - Magnetar

Hi,


I'd recommend changing this slightly - put your client_id and secret in a different input, and use the Append Fields tool to put the two together.  That way you will pass your client_id and secret through for each call.

If you are calling services with different client_id and secret, consider a Join instead of Append Fields.

 

Otherwise, this looks good!  The download tool will automatically loop through all requests, and then you can later parse them out into specific logic.

jt7Princeton
6 - Meteoroid

So I think I can just put those 2 values in the payload of my download tool.  Essentially the first step is to call that clientauth endpoint with a post and those 2 values to get a token.  I then use that token in the header for all subsequent calls.  So like you said, I created a separate input with just the URL and put the post values in the 1st download tool.  I am guessing that will give me the token back.  I see the download tool has output as a string.  What tool would be the best to capture that and ultimately pass it to the next download tool's header that loops through all the URLs?

 

I noticed the download tool can have only 1 input so I couldn't hook up a 2nd input tool (with my URLs) and the precededing download tool (with the token output) to a subsequent download tool.

 

Thanks!!!

Claje
14 - Magnetar

Usually I end up parsing out the response data to find the information I want, using Text to Columns (split to rows on \n for new line characters).  Then I use a filter and/or formula to extract the specific data elements I want.

From there I would recommend following the process I recommended before - take your newly generated token data and use a Join to connect each token to the respective service call, then pass that output to the Download tool.  You'll just need some way to identify that a token generated by the "buildings" call is tied to your new "buildings" query.

jt7Princeton
6 - Meteoroid

Thanks.  The token received from the first client auth is the same one used for all subsequent calls.  It's more of a session token than a call token.

Claje
14 - Magnetar

Gotcha - in that case use Append Fields to append the Token to ALL of your calls for step 2.  I'd just make sure you are only passing in one Token row into that Append fields tool.

jt7Princeton
6 - Meteoroid

Thanks so much.  I have the auth working to get the secret token.  I then have to use that in the header of the subsequent calls.  When I try to do that in the second download tool, I get an error that x-ems-api-token can't be found.  Am I setting up the download headers correctly for this third header (first screenshot)? If you look at the second screenshot below, it looks like the input data is coming in correctly.

 

------last download tool config-------

2019-05-03_12-03-39.png

 

-----------------Input data and workflow---------------

 

2019-05-03_12-07-08.png

jt7Princeton
6 - Meteoroid

I also tried removing the manual header and just selecting the x-ems-api-token from the bottom (as described here https://help.alteryx.com/2018.3/Download.htm) and got the same error.

jt7Princeton
6 - Meteoroid

Never mind!  I got it!  Had some extra spaces in my field name in the previous step.

Claje
14 - Magnetar

That's great!  Glad it worked!

Labels