Dev Space

Customize and extend the power of Alteryx with SDKs, APIs, custom tools, and more.
SOLVED

Making POST API calls to a Tableau Server using the Download Tool

wguicheney
5 - Atom

Hello everyone,

 

I'm currently working on a project to automate subscriptions using an Alteryx workflow. The strategy involves downloading (1) a list of relevant users from my organization's SQL database, (2) finding each users Tableau Server ID, (3) checking that list against the people subscribed to a specific view, and (4) subscribing those that aren't subscribed yet, or removing those that have left the organization.

 

I am stuck at the last step, which involves making a POST API call to the server to create new subscriptions. There seems to be very little information from the community about doing this in Alteryx, as there are already very few people doing this in Java or Python. 

 

The POST call involves passing two parameter values api-version and site id, as well as five attributable values, subscription-subject, content-type, content-id, schedule-id, and user-id. I have included all 5 in my call and triple-checked all their values. I have also naturally included an X-Tableau-Authorization token in my headers. Here is what the setup of my download tool looks like.

 

1.PNG 2.PNG 3.PNG 

 

I am getting the following error: a 100 Continue, followed by a 500 Internal Server Error. Not much help there, and as I am a Site Administrator but not a Server admin, I don't have access to the logs to explore further. 

 

4.PNG

 

The online Tableau developer documentation is providing me with lots of different information, such as "For POST and PUT requests, the request should include the Content-Length and Content-Type headers."   but I am not sure this is true, or how a Content-Length header should look like for example. The documentation does not provide many examples of POST requests.

 

Does anybody have any experience making POST API calls to the Tableau Server using Alteryx's Download tool? Any help would be greatly appreciated. 

12 REPLIES 12
PetrT
Alteryx
Alteryx

Hi wguicheney,

I think you should definitely build XML with all the paremeters you mentioned as is described in Tableau REST API reference.

RequestBody.PNG

Send this XML as a payload.

You should also add HTTP header Content-Type with value of "application/xml or "text/xml"

 

Hope it will help you.

 

Regards

 

Petr

 

wguicheney
5 - Atom

Hi Petr,

 

Thanks for the input. I ended up managing to get it working by following the following steps:

 

1) Copy/patsing the Request Body provided in the Tableau Documentation into a Formula tool to build the "payload" manually. Here's what it looks like:

Capture.PNG

 

2) Switching my Download tool a Custom POST request (Just select Custom in the API call options and write POST)

 

3) Using only X-Auth-Code as a Header (No need for a Content-Type header)

 

 

Was a real shot in the dark as neither Tableau nor Alteryx provided any documentation on this!

Amarendra
10 - Fireball

Hi @PetrT ,  @wguicheney

 

I am trying to do something similar and was not able to come around with a solution. Is it possible for you guys to share the workflow? 

 

Thanks, 
Amar

PetrT
Alteryx
Alteryx
Hi @Amarendra, you can check how we handle REST API calls in Tableau metadata loader. It is part of Alteryx Connect loaders package available at http://licenses.alteryx.com Petr
Amarendra
10 - Fireball

@PetrT We do not have the licenses to Alteryx Connect. I can only use the download tools for now. 

PetrT
Alteryx
Alteryx
Hi @Amarendra, there is nothing to do with Connect itself. I just wanted to point you to our loader which is regular workflow utlizing Download tool. See the file attached (you will probably miss some Connect related tools, but you can still have look on how we work with API using regular Download tool). But nowadays you have even other options. I would consider to use Tableau server-client-python https://github.com/tableau/server-client-python. You can use this module in your own Python SDK based tool or in our Python tool. Petr
t-bone
7 - Meteor

Hi all,

I am working on an Alteryx workflow to move Tableau Workbooks from one Tableau Server Project to another.  The basic Workflow is very similar to the steps documented in this tread however I keep getting a "resourse not found" error.  

 

In my formula tool, I cant figure out out to get the tsRequest xml text to take as even though I am enclosing the whole thing in quotes, the formula tool is not accepting the xml.  I therefore am trying to configure the formula tool in a format that looks like this:

[server] + "/api/2.4/sites/" + [site_id] + "/projects/" +  "project id where I am trying to move the workbook to" + "/workbooks/" + "workbook that I am trying to move id" 

 

other key pieces of this workflow is a publish to tableau server tool before the formula that gets me a auth token and a download tool after the formula tool that is set up this way:

basic tab - url field = url

header tab - x-tableau-auth selected

payload tab - http action = custom "POST" and compose query string/body is selected

 

Any enlightenment would be appretiated.

 

Thank you,

 

~ Eric Marowitz

 

 

neeleshapatil1
8 - Asteroid

Hi Eric,

Can you pls confirm if you have received any solution?

I am also working on same use case of moving downloaded .twb files from one server to another.

sathiya
8 - Asteroid

My Use case that worked may help your issues  - Add user if they do not exists in the server

1. We get the authentication token using publish to tableau

2. Create all variables -URL , RequestXML , Servername - pass to download tool

3. Please see screenshot for download tool  - Basic and Header are same as the screenshot in the post - In Payload-  use Take a query String/Body from Field - i created the XML using formula field

4. Keep Fiddler open to see how the call goes - if any issue take the information and use another tool call Postman or Rest tools or CURL command - to test your call.

 

For question about formula not acception quotes - either you can use escape characters or add single quote around double quotes

'"<tsRequest><user id="' + [USER_LUID] + '"/></tsRequest>"'

 

alteryx-tableau.jpg