Skip to content

Getting Shareable link from a query ID #1583

@samelamin

Description

@samelamin

Hi All,

We want to use the system__activity model to look at the most widely used dashboards and get their shareable URL via the SDK

Unfortunatly when querying via the SDK I keep getting the numeric id for the query and not the slug URL, I even tried creating a custom look but on the looker UI I see the link as a slug but the SDK still returns the int

Is there a way to easily get the shareable URL given a query id?

So far this is the code I have been attempting to write. It works when the id is a slug but not when its numeric

def get_query_share_url(query_id):
    try:
        query = sdk.query(query_id)
        return query.expanded_share_url
    except Exception as e:
        print(f"Error getting share url for query {query_id}")
        print(e)
        return None

If I use the numeric ID, the code throws an exception

    <style type="text/css">
        body {
            background-color: #2e343f;
            color: white;
            height: auto;
            font-family: Open Sans, Helvetica, Arial, sans-serif;
        }
        .message {
            width: 100%;
            max-width: 760px;
            margin: 0 auto;
            margin-top: 135px;
            text-align: center;
        }
        h2, h3 {
            font-weight: normal;
        }
        a {
            color: white;
        }
    </style>
</head>
<body>

    <div class="message">

        <img width="210" height="84" src="https://wwwstatic-a.lookercdn.com/logos/looker_all_white.svg" alt="Looker">

        <h1>Looker is unavailable.</h1>

        <h2>If you typed in a URL, double-check the spelling.</h2>
        <h2>This may also be due to a temporary condition such as an outage, <a href="https://docs.looker.com/relnotes/hosted-maintenance-hours">scheduled maintenance</a> or upgrade.</h2>
        <br>
        <h3>
          If this message persists or you have any concerns, <br> contact us from
          <a href="https://help.looker.com">help.looker.com</a> and we'll respond promptly.
        </h3>

    </div>

</body>
</html>

    documentation_url: 
    error_doc_url:     
    error details:

I must be missing something obvious because there must be a simple way of getting the slug given an ID. Any help would be appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3Priority 3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions