Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
yomato
Contributor
Contributor

Qlik REST API GET /v1/data-sets/{data-set-id} endpoint returns 401 to OPTIONS request

Hey there,

I am using Qlik Cloud and trying to fetch dataset information using JS fetch API. The following code is sending an OPTIONS request and Qlik Cloud server responds with 401 to this request.

 

 

async function getFields(dataset, tenantUrl, bearerToken, integrationId) {
    try {
        const response = await fetch(`${tenantUrl}/api/v1/data-sets/${dataset}`, {
            method: 'GET',
            headers: {
                'Authorization': `Bearer ${bearerToken}`,
                'Content-Type': 'application/json',
                'qlik-web-integration-id': `${integrationId}`,
            }
        });
        const data = await response.json();
        return data['schema']['dataFields'];
    } catch (error) {
        console.error('Error fetching fields:', error);
    }
}

 

 

I tried the method suggested in this post and was able to send this request without any issues. When I disabled web security in my Chrome browser, there were no preflight requests.

https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-Response-to-preflight-request-doe...

The following code also sends OPTIONS requests without any problem, the server responds with 204.

 

 

async function getItems(tenantUrl, bearerToken, integrationId) {
    try {
        const response = await fetch(`${tenantUrl}/api/v1/items`, {
            method: 'GET',
            headers: {
                'Authorization': `Bearer ${bearerToken}`,
                'Content-Type': 'application/json',
                'qlik-web-integration-id': `${integrationId}`,
            }
        });
        const data = await response.json();
        return data['data'];
    } catch (error) {
        console.error('Error fetching datasets:', error);
    }
}

 

 

I don't get this error on any endpoint other than this one. I only use the fetch API without any third-party library. Why this is happening?

update: I also got this error with this request GET /v1/data-sets/{data-set-id}/profiles 

It appears that there is a common issue with requests related to data sets.

Labels (2)
0 Replies