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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Mala
Partner - Contributor II
Partner - Contributor II

Creation of app and loading script in it with Qlik API end points

Hi ,

We are attempting to create a app and load the script in it through the Qlik Cloud API. 
 
While we received a positive response from both API call, we noticed that there was no script loaded in the app when we checked from the Qlik Cloud and the app is getting created with no Data manager, no Data load editor in Qlik Cloud. We are following all the steps as per the official article - https://qlik.dev/apis/rest/apps/
 
Could anyone kindly provide us with some insights or guidance on this matter? Your expertise and advice would be greatly appreciated.
 
API endpoints used:
  1. Creation of app: api/v1/apps
  2. Load Script : api/v1/apps/<appid>/scripts
Labels (3)
7 Replies
Øystein_Kolsrud
Employee
Employee

You'll need to perform another API call to have the engine execute the script as well. Perhaps that is what is missing on your side? This is what I did using the QlikSenseRestClient library https://www.nuget.org/packages/QlikSenseRestClient/

var url = "<url>>";
var apiKey = "<apiKey>";

var client = new RestClientQcs(url);
client.AsApiKey(apiKey);

var body = JObject.FromObject(new { attributes = new { name = "MyApp" } });
var rsp = client.Post<JObject>("/api/v1/apps", body);
Console.WriteLine(rsp.ToString());
var appId = rsp["attributes"]["id"].Value<string>();

var script = "Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;";
body = JObject.FromObject(new { script = script, versionMessage = "This is my version" });
client.Post($"/api/v1/apps/{appId}/scripts", body);

And then this call to run the script and load the data into the app:

body = JObject.FromObject(new { appId = appId });
Console.WriteLine(client.Post("/api/v1/reloads", body));

 

Mala
Partner - Contributor II
Partner - Contributor II
Author

Hi , 

We are running all the there API calls through Postman using client ID and secret , and yet we couldn't get any positive response on that.

 

Øystein_Kolsrud
Employee
Employee

You mean you get an access token from an OAuth client? Maybe there's something missing when it comes to the scope configuration of the client? I suggest you try authenticate with an API key instead and see if you get it to work using that flow. That way you will at least know if there's anything wrong with the way you call the endpoints.

You can read more about scopes and OAuth here: https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Admin/mc-create-oauth-cl...

Mala
Partner - Contributor II
Partner - Contributor II
Author

Yes ! As mentioned it is working with the API Keys , but not with the client ID and secret and the OAuth credentials are having all the scopes required for the app creation and loading the script. Eventhough, the app created with the OAuth client is getting create as empty with no Data loader and Data editor

(Scopes: apps apps:export apps:read apps.data:export apps.image:export users users:read admin.apps admin.apps:export admin.apps:read admin.automations admin.automations:read admin.spaces admin.spaces:read admin.users admin.users:read identity.name:read identity.email:read identity.subject:read identity.picture:read user_default admin_classic automations automations:read automl-deployments automl-experiments spaces.data spaces.data:read spaces.managed spaces.managed:read spaces.shared spaces.shared:read dataset lineage:create)

Øystein_Kolsrud
Employee
Employee

Are you using impersonation? Otherwise the app will be created as a bot user when authenticating like that. Maybe you user simply can't see the contents of it? You can change the owner of an app in the administrator section of QCS, so have a look there.

Mala
Partner - Contributor II
Partner - Contributor II
Author

The user account through which the OAuth client is created is a Tenant Admin, and using the same we are running the API calls .So, the user I having all the privilege.

Øystein_Kolsrud
Employee
Employee

OK, but I don't think tenant admins can see the content of users private apps. And the user set as the owner of that created app will be a bot-user, not the user who created the OAuth client. You can verify this by looking at the response to your call to POST "/api/v1/apps". You'll see in the attributes section of the response lines like this:

...
"owner": "qlikbot\\<id0>",
"ownerId": "<id1>",
...

If you change the owner of the app then you should be able to see the data. Or if you publish the app to a stream. That should do the trick as well.