
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Detailed python scripts to Link Qlik Cloud.
Hello Folks,
I was trying to generate detailed python scripts to read data from a qlik cloud table, output it as a pdf file on my laptop
I keep on encountering error 401. i,e Failed to fetch data. Status code: 401.
here is my code:
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
I have gotten the solutions,
(1) I need Api_key.
(2) I used pytoqlik library.
p2q = pytoqlik.Pytoqlik(api_key=key, tenant=url, appId=ID)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey there,
Possibly try this...
Here are a few steps you can take to troubleshoot and resolve this issue:
-
Verify Credentials: Ensure that your
qlik_username
andqlik_password
are correct. These should be the credentials you use to log into the Qlik Cloud service. -
Authentication Method: Qlik Cloud might not support basic authentication (username and password) in the way you've implemented it. Usually, Qlik Cloud uses API tokens for authentication. You'll need to generate an API token from your Qlik Cloud account and use that for authentication instead of username and password.
-
API Token Usage: If you are using an API token, the header format is usually
"Authorization": "Bearer <your_api_token>"
. Make sure you're using the correct format. -
API Endpoint: Ensure that the URL you are using to fetch data is correct. Verify the base URL and the specific endpoint for fetching table data.
-
API Permissions: Make sure that your account or API token has the necessary permissions to access the data you're requesting.
-
API Documentation: Consult the Qlik Cloud API documentation for specific details on how to authenticate and fetch data. There might be specific steps or parameters required.
Here's an example of how you might modify the authentication part of your script if you were using an API token:
# Qlik Sense Configuration
qlik_base_url = "https://ioco2.eu.qlikcloud.com/"
qlik_app_id = "d0c200c8-b3bb-4157-81b7-4d18d44856a3"
qlik_table_object_id = "tNfNKkC"
# API Token (replace with your actual API token)
qlik_api_token = "your_api_token_here"
# Fetch data from Qlik Sense with Bearer Token for authentication
qlik_data_url = f"{qlik_base_url}/api/v1/apps/{qlik_app_id}/tables/{qlik_table_object_id}/data"
headers = {
"Authorization": "Bearer " + qlik_api_token
}
response = requests.get(qlik_data_url, headers=headers)
# ... rest of your script
Remember to replace "your_api_token_here"
with your actual API token. If you need help generating an API token in Qlik Cloud, you should consult their documentation or support resources.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
I have gotten the solutions,
(1) I need Api_key.
(2) I used pytoqlik library.
p2q = pytoqlik.Pytoqlik(api_key=key, tenant=url, appId=ID)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Scotchy I tried your approach it did not work. I am using window computer. here is what I did :
# Hello Qlik Cloud Python Program
import requests
import pandas as pd
import matplotlib.pyplot as plt
import base64
import json
# Qlik Sense Configuration
qlik_base_url = "https://mytenant.eu.qlikcloud.com/" # I do not want to show my real tenant on public
qlik_app_id = "f5555629-bb12-4983-854b-1ed7c9682f55"
qlik_table_object_id = "ZgGPbV"
qlik_api_token = "I used correct api key here"
qlik_data_url = f"{qlik_base_url}/api/v1/apps/{qlik_app_id}/tables/{qlik_table_object_id}/data"
headers = { "Authorization": "Bearer " + qlik_api_token }
response = requests.get(qlik_data_url, headers=headers)
# Check for successful response status
if response.status_code == 200:
try:
table_data = response.json()
except requests.exceptions.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
table_data = None
else:
print(f"Failed to fetch data. Status code: {response.status_code}")
table_data = None
the output was
Failed to fetch data. Status code: 401
