[Python] Retrieve JSON response from a Tableau dashboard with Python

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to retrieve the JSON response from a Tableau dashboard at this URL: https://cde.state.mn.us/CrimesAgainstPerson/CrimesAgainstPerson

    I believe the data is contained in another URL, something like https://cde.state.mn.us/vizql/w/MNC...1/commands/tabdoc/categorical-filter-by-index, where the code after sessions/ is variable.

    I have tried the following POST:

    url = "https://cde.state.mn.us/vizql/w/MNCDE-CrimesAgainstPerson/v/CrimesAgainstPerson/sessions/CDED047B5C794CAA87AAC5024F211E1B-1:1/commands/tabdoc/categorical-filter-by-index"

    headers = {
    "Accept": "text/javascript",
    "Content-Type": "multipart/form-data; boundary=gNQsUgpQ",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) "
    "Chrome/134.0.0.0 Safari/537.36",
    }

    data = {
    "visualIdPresModel": {
    "worksheet": "Offenses",
    "dashboard": "Crimes Against Person",
    },
    "globalFieldName": "[sqlproxy.1cnbk1z1ube6hd1d0i73a1pg9633].[none:Calculation_218987581473460224:nk]",
    "membershipTarget": "filter",
    "filterUpdateType": "filter-delta",
    "filterAddIndices": [164],
    "filterRemoveIndices": [],
    "telemetryCommandId": "1inan7fhs$dmwm-mk-ys-be-iqzo5j",
    }

    p = requests.post(url, data=data, headers=headers)


    But this returns a 400-level response code.

    I imagine one needs the code in the actual URL after sessions in order to retrieve the data, but I cannot figure out how to collect this code from the dashboard landing page.

    Continue reading...

Compartilhe esta Página