Easily shop verified, supported, and secure Partner and Alteryx built Add-Ons on Marketplace.
LEARN MOREThe attached example shows how to use the Alteryx Private Gallery API Runner macro. If you have an alteryx private gallery setup, you can use your key and secret to hit the various api endpoints. See this post and this post which have details on how to obtain your key and secret as well as background on how the macro was built. After opening the yxzp in alteryx, to use the macro in your own workflows, you will need to either: 1) copy the macros (.yxmc) to your workflow directory, or 2) copy the macros (.yxmc) to your macro repository.
Key: Your private gallery alteryx API key obtained from your private gallery. There are separate user and admin keys if you have access to both.
Secret: Your private gallery alteryx API secret obtained from your private gallery. There are separate user and admin secrets if you have access to both.
URL: The complete API endpoint that you are sending data to. The example has a list of the various endpoints. You can also access the interactive demo from your keys page. Be sure to replace the various placeholders (Server.domain, Your_App_ID, Your_Job_ID, Your_Output_Id etc).
GETPOST: Toggle for type of request. Most of the endpoints are GET while there are a couple POST. As of 1/26/2023, PUT and DELETE were added as well.
Output String or Blob: You can determine the format that you want the response to be sent back in. String will normally work, but for the endpoints that download outputs or workflows, blob will allow you to then save the file. See the example 5.
Body checkbox (Optional): Allows you to send a body with your POST/PUT request, either from a field or just typing into a textbox. See example 3. Note that you will need to escape the \ and " character by using \\ and \" inside any strings. For example, to get the string like this through:
{"questions": [{"name": "FileIn", "value": "abc"123" },{"name": "FileOut", "value": "\\server.com\folder\D"}]}
you would actually enter:
{"questions": [{"name": "FileIn", "value": "abc\"123" },{"name": "FileOut", "value": "\\\\server.com\\folder\\D"}]}
Additional Parameters checkbox (Optional): Allows you to send additional parameters with your request. They must be ordered alphabetically. The API macro already includes the various oauth parameters (when not using Oauth2). The format is ParameteName=ParameterValue. If you enter more than one, separate with an &. If the parameter name comes before oauth, use the Before box. includeMessages=FALSE is an example. If the parameter name comes after oauth, use the After box. search=Smart is an example. See example 1.
Authentication method: Before 21.4 and prior use Oauth1.0a. You have 4 options: R, Python, Alteryx and Alteryx Abacus. R requires the Alteryx Predictive Tools. Abacus requires Alteryx Abacus installation. 22.1+ must use Oauth2. Versions before 21.4 cannot use Oauth2. 21.4 can use either Oauth1.0a or Oauth2, you'll just need to ensure that the Authentication matches the URL you're using. Oauth2 gets the Authorization token and includes it with your call, so you don't have to hit the authorization token endpoint.
Examples:
1 Get App Id - Hits the subscription endpoint which returns your workflows in your private gallery. It demonstrates the after optional parameter. This endpoint can be used to get the app id which will be used in later api endpoints.
2 Get App Questions - Hits the workflow endpoint with a GET request to return the list of interface tool names that you can then use in the Run Job example.
3 Run Job - Hits the workflow endpoint with a POST request to start a job. It returns the AppID which will be used in later examples. There are 2 examples that include a body, and 1 that does not include a body. The Body is optional, depending on whether your app has any interface tools. If you want to include a body, you can either specify which field contains the body, or you can type your body in manually.
4 Get Job status - Using the Job ID from Run Job example, you can check the status of your job as well as obtain the IDs for any outputs for a completed job. I've used the optional before parameter box to exclude messages from being returned.
5 Get Job output - Using the Job ID from the Run Job example and the Output ID from the Get Job Status example, you can retrieve the output file(s). Notice it's a 3 step process from beginning to end (1 Start job, 2 check status, 3 obtain file), where step 2 would have to be run over and over until the status is 'complete'. In this example the macro is configured to output as a blob, which is then saved to the workflow directory as a csv.
Updates:
2022-01-04
-False Errors about __URL___pctEnc were fixed.
-Body is now optional, and you can either feed in a field or type it in manually.
-Optional additional parameters are a new feature in this version of the macro.
-The ability to hash with python was added with this version. R requires the predictive tools, and appears to be more stable. Python may report false metadata issues.
2022-01-05
-Fix 2 big issues with the Python hashing method. It's now just as stable as R.
2023-01-26
-Added PUT and DELETE which are used for V3 endpoints.
-Added Authentication Options: Alteryx, Alteryx Abacus and Oauth2.0. See more info above. Abacus is lightning quick but requires separate installation. Oauth2.0 is needed for 22.1+ usage. Oauth2 gets the Authorization token and includes it with your call, so you don't have to hit the authorization token endpoint.
2023-02-23
-Updated Oauth2 to work with Localhost
2023-05-15
-Updated Oauth2 to hopefully work all urls.
-Updated the optional parameters logic to work for Oauth2 (which doesn't send any of the Oauth1 parameters).
Thanks for this awesome macro. I am trying to use this macro for migrating workflows from one environment to another. I am struggling to make the POST API to work which is used to import packages to target environment. ("/admin/v1/workflows"). This API takes input as multipart form data and I am not able to figure out how to send that information using this tool, please provide an example. Appreciate your help.
Hi @ananthtony , I have not been able to figure out multipart form data to date using the normal download tool.
Thanks patrick for the reply.
Hi @patrick_digan ,
Thank you for creating this macro and sharing with us. Great tool!
I have an issue though and I'm hoping you can figure out how to solve it. I am trying to download workflows from the gallery and save them in local files to analyze the tools that are used within them.
The macro itself do it's job as expected, nothing wrong there. However, the blob output tool generates files like this:
Do you have an idea what is wrong here? How could I get the files humanly readable?
@Laszlo_D great to hear! What file type are you saving the blob as? I would try a .yxzp, I think that's the extension the gallery generally uses
It doesn't matter what filetype I choose. It is always the same. I tried xml, yxzp, yxmd, csv.
Have you tried doing what I am doing? Did you not have this issue?
Solved! It was that my workflows are saved as yxwz, that is zipped package. I had to unzip them and there they were my workflows!
Hi there,
what version of Alteryx this need to be to unzip the file? it saying its my version is too old, and i am using 2020.2
@PengASU Hello! I used 2021.2.
Love the tool! We had a workflow that was running quite successfully up until our upgrade from 2021.2 to 2022.1 recently. Now I seem to be getting 401 Unauthorized errors on any call I make. I confirmed my Key and Secret are correct through the Swagger Interface, all calls work there (V1, V2 and V3). Is anyone aware of any changes I need to make to the Macro to get it working with a server 2021.4 and newer?
@Matt19 22.1+ now uses Oauth2 (pre 21.4 used Oauth1.0a). I've just added Oauth2 as an option yesterday. Try downloading the latest version of the tool and that should work for you. Note that the URL from 21.2 will be slightly different from the URL needed for 22.1 (the switch from Oauth1.0a to Oauth2 uses a slightly different URL base).
@patrick_digan - Thanks for the response, I'll take a look, appreciate all your hard work on this!
@patrick_digan Thanks for creating this macro! I had developed a workflow leveraging this macro but after a recent upgrade from 2021.4 to 2022.1 it stopped working. I tried the most recent version of your macro which has the Oauth2 option, but I keep getting the 401 Unauthorized error. The V1,V2 endpoints work when I test on Swagger so I think the key/secret should not be an issue. Any idea on why I keep getting this error? Thanks!
@prasannaraut huh, if you can get the swagger to work, I agree that it's not a key/secret issue. And I assume you're copying the url straight from swagger as well? I'm curious whether you're actually getting a token in alteryx, but that would require debugging/tweaking the macro.
@patrick_digan I tried pasting from swagger which uses "http://localhost/webapi/user/v2/workflows/{appId}/jobs" as well as what used to work before - "http://localhost/gallery/api/user/v2/workflows/{appId}/jobs/" . To see if the token is being generated, I added an output from the Oauth2 macro. Looking at the output, the "Authorization" field has value "Bearer" - which I think is supposed to be something like "Bearer <tokenvalue>", so maybe the token is not being generated.
@prasannaraut I see, thanks for the details! I had mistakenly assumed that the base url would have .com in it. I've updated the Oauth2 macro to work with localhost as well. You'll want to use the URL from swagger "http://localhost/webapi/user/v2/workflows/{appId}/jobs"
Thanks @patrick_digan! Its working now, appreciate all your hard work on putting this macro out :)
@patrick_digan Hello Patrick. I stumbled across your API tool and I'm trying to get it to work. Your previous one worked for me in the past, but we upgraded to 2022.1 and now I'm trying your newer one. I cannot get it to work though. It should be as simple as the API and Proper Key and Secret right?
@superjesse It should be that simple. What's the error that you're getting?
The server admin may need to ensure the correct URL is loaded into the Web API Address in the server system settings (I'm on 21.4 but it should be the same). You'll have to copy it letter for letter. We use aliases for our servers, so we had to enter the alias into the web api address.
One thing you can check is the swagger docs to see if you can add your key/secret there and get anything to return. https://mycompany.com/webapi//swagger/ui/index#!
@patrick_digan Thank you for the response. I'm the admin so I verified we had the WEB API address on the gallery. Yes, my key and secret work in swagger.
I get the 401 Unauthorized error.
@superjesse thanks for the info! In order to get the Token as part of Oauth2, I'm assuming your URL is of the format https://server.domain.com/webapi/..... or //localhost/webapi... . I'm using regex and looking specifically for .com or localhost. Perhaps this is where the issue is occurring for you?
@patrick_digan Hello Patrick again. I dug into the macro and focused on the Oauth2 piece. I was able to get a 200 success when I just enter the base gallery URL. Your formula adds /webapi/oauth2/token and its successful with that URL. I tried more specific API formats, and it errors when I try an API (for example: v3/workflows).
@patrick_digan Hello Patrick. Our domain doesn't end with .com. It ends with .media.
@superjesse I see, I updated the Oauth2 macro to hopefully work with all domains. You can re-download and check it out. Instead of looking for localhost or .com, I'm looking for the first single / so that I can build the correct token url. For example, https://server.domain.xyz/webapi/v1/workflows/subscription will use a token url of https://server.domain.xyz/webapi/oauth2/token. It will fail if somebody changes out the webapi part for something else.
@patrick_digan Yes, that worked. Thank you!!!
Hi Team, I have a master workflow triggering 3 consequent workflows using this macro - Is there a way that I could kill the jobs that got triggered ?
I have been looking around, but have not found a good answer. Do you happen to know how to set the priority of the job and how the URL is structured do send it through the macro?
Hi
I need to run altery wf with api oauth2.0 using macro, the sample you provided not showing me option to select oauth method.Look like it is for oauth 1.0.
Can you provide me appropriate macro.