divinorum-webb / tableau-api-lib

An API library that allows developers to call on the methods listed in Tableau's REST API documentation.
MIT License
96 stars 34 forks source link

Debug: How to see full URL of request? #73

Closed danhislop closed 2 years ago

danhislop commented 2 years ago

I have an issue with filtering where I can properly filter using postman and Tableau REST API directly, however using the otherwise reliable tableau_api_lib it does not.

How can I print/log to debug the actual request being sent to the tableau server? example of GET request via postman which works: https:///api/3.8/sites//views//data?vf_Signal%20Types=Keypress&vf_Network%20Name=TEST

The generic request works, it just seems to ignore the filter.

divinorum-webb commented 2 years ago

Hey @danhislop, you can see the latest active_endpoint associated with your connection instance by running conn.active_endpoint. Same with headers and request JSON bodies: conn.active_headers and conn.active_request, respectively. That all assumes your connection instance is stored in a variable named conn -- just use whatever variable you initialized your connection into.

Hope this helps!

divinorum-webb commented 2 years ago

Also to clarify, it looks like the URI you are specifying above is missing the site id and view id portion: GET /api/api-version/sites/site-id/views/view-id/data?vf_<fieldname>=filter-value

You can also try using the built-in querying function that will return your view data as a Pandas DataFrame. Looks something like:

from tableau_api_lib.utils import querying

conn = TableauServerConnection(config_json=config, env="devyx")
conn.sign_in()

view_data = querying.get_view_data_dataframe(
    conn=conn,
    view_id="51e4e035-ba78-497a-b4e9-408d339b59ba",
    parameter_dict={
        "filter1": "vf_Sub-Category=Chairs"
    }
)

Running the above against one of my test workbooks gets me:

image
danhislop commented 2 years ago

Thank you the first tip helps so much! it works and now I can see how exactly things are being passed. especially helpful to know the %20 is going in correctly.

Regarding the missing site id, I typed a string in to redact it, maybe something like "/" - looks like the redaction was redacted : )

(haha even trying to type the word redacted inside < and > above but its only proving my hunch since its hiding it in this comment too : ) )