Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
Over the last few days I've been testing the Data Sets APIs https://qlik.dev/apis/rest/data-sets/ and I'm having some trouble understanding how to properly create a dataset using the POST method.
In the documentation, some properties are required in the request body, but their purpose is not very clear to me.
In particular:
These fields seem to be mandatory, but I can't understand:
I already have a valid Snowflake Data Connection and I can create datasets through the Qlik UI wizard without issues.
However, when trying to create the same dataset through APIs, I'm struggling to understand how qri and secureQri should be populated.
Has anyone successfully used this API or figured out the correct workflow?
Thanks!
Cristian
Hey Cristian,
These fields are all defined here:
https://qlik.dev/apis/rest/data-sets/
Please let me know if this helps and if not, I am happy to assist further.
We can't use this API to create Datasets based on Databases. This API was meant to be used to file based sources - I know, the documentation is terrible on this one.
So, there is an undocumented path, easily discoverable if you use Developer Tools in any browser.
Long story short, Qlik uses a different endpoint for Database related Datasets:
https://<your-tenant>.qlikcloud.com/api/v1/catalog/catalog-integration/actions/create-hierarchy-for-...
You can call this endpoint using POST method, use same bearer authorization you have for other endpoints, and the body message is pretty nasty. See an example below:
{
"spaceId": "66c4b5b6314eb13bee4f457a",
"connectionId": "597d85bc-4845-4167-b7ff-c1eab16216a3",
"schema": "public",
"tables": [
{
"tableName": "fact_review_item",
"selectionScript": "[fact_review_item]:\r\nSELECT \"review_item_id\",\r\n\t\"review_id\",\r\n\t\"item_code\",\r\n\t\"result\",\r\n\t\"failure_description\",\r\n\t\"suggested_fix\"\r\nFROM \"public\".\"fact_review_item\";",
"additionalProperties": {
"fields": "[{\"name\":\"review_item_id\",\"fullName\":\"review_item_id\",\"nativeType\":\"uuid\",\"isKey\":true,\"isSelected\":true},{\"name\":\"review_id\",\"fullName\":\"review_id\",\"nativeType\":\"uuid\",\"isSelected\":true},{\"name\":\"item_code\",\"fullName\":\"item_code\",\"nativeType\":\"varchar\",\"isSelected\":true},{\"name\":\"result\",\"fullName\":\"result\",\"nativeType\":\"review_result\",\"isSelected\":true},{\"name\":\"failure_description\",\"fullName\":\"failure_description\",\"nativeType\":\"text\",\"isSelected\":true},{\"name\":\"suggested_fix\",\"fullName\":\"suggested_fix\",\"nativeType\":\"text\",\"isSelected\":true}]",
"tableRequestParameters": "[{\"name\":\"owner\",\"value\":\"public\"}]"
}
}
]
}I haven't exhaustively tested this message body, but it appears that all fields are mandatory.
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com