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

Announcements
Congratulations to the new Qlik Luminary and Partner Ambassador class! Meet them here
cancel
Showing results for 
Search instead for 
Did you mean: 
cristian_dalsanto
Partner - Contributor III
Partner - Contributor III

Activating On-Demand Reports via API

Hi everyone,

I'm trying to identify and test all the API endpoints required to clone an app that has a Tabular Excel report associated with it.

So far, I've managed to successfully clone the app and re-associate the report template, as the template association is lost during the app cloning process.

The last step I'm missing is enabling the On-Demand functionality, which can be done from the UI through the following step:

cristian_dalsanto_0-1788254064690.png

 

Does anyone know if it's possible to perform this operation via API? If so, which endpoint should be used?

Thanks in advance!

Cristian

Labels (3)
1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

This is the endpoint the Qlik client uses for enabling on-demand reporting:

https://qlik.dev/apis/rest/report-templates/#patch-api-v1-report-templates-id

Here's a small C# example showing how to use it programmatically to enable HTML reports:

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

var template = client.Get<JObject>($"/api/v1/report-templates/{templateId}");

var p = JObject.FromObject(new
{
    op = "replace",
    path = "/onDemandSettings",
    value = template["onDemandSettings"]
});
p["value"]["output"] = new JArray("HTML");

client.Patch($"/api/v1/report-templates/{templateId}", new JArray(p));

 

View solution in original post

6 Replies
Chanty4u
MVP
MVP

cristian_dalsanto
Partner - Contributor III
Partner - Contributor III
Author

Hi @Chanty4u , thanks for the links!

I've already checked both pages, but unless I'm missing something, I can't find an API endpoint for the specific operation I'm looking for.

The Report Templates API seems to cover the CRUD operations on the template itself, while what I need to automate is the activation/configuration of the template for On-demand reporting.

From the UI, this is the step where you select On-demand, configure the available file formats, title and description, and save it. After that, the template shows On in the On-demand column.

Do you know if this specific configuration is exposed through a public API (possibly a different endpoint from the Report Templates API)?

Thanks!

 

Øystein_Kolsrud
Employee
Employee

This is the endpoint the Qlik client uses for enabling on-demand reporting:

https://qlik.dev/apis/rest/report-templates/#patch-api-v1-report-templates-id

Here's a small C# example showing how to use it programmatically to enable HTML reports:

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

var template = client.Get<JObject>($"/api/v1/report-templates/{templateId}");

var p = JObject.FromObject(new
{
    op = "replace",
    path = "/onDemandSettings",
    value = template["onDemandSettings"]
});
p["value"]["output"] = new JArray("HTML");

client.Patch($"/api/v1/report-templates/{templateId}", new JArray(p));

 

TheLazyDeveloper
Contributor III
Contributor III

Hi,

How did you manage to successfully re-associate the report template? We're dealing with the same issue when cloning the app and the template association is lost.

cristian_dalsanto
Partner - Contributor III
Partner - Contributor III
Author

Hi @TheLazyDeveloper ,

First, I retrieved the template id from the source app using:

curl --silent --show-error \
"https://myhost.xx.qlikcloud.com/api/v1/report-templates?sourceAppId=xxxxxx-xxx-xxxx-xxxx-xxxxxxxxx&limit=100" \
-H "Authorization: Bearer <TOKEN>" \
-H "Accept: application/json"

 

Then, I downloaded the file locally:

 curl --fail-with-body --location \
--request POST \
"https://myhost.xx.qlikcloud.com/api/v1/report-templates/xxxxxx-xxx-xxxx-xxxx-xxxxxxxxx/actions/download" \
-H "Authorization: Bearer <TOKEN>" \
-H "Accept: application/octet-stream" \
--output "/Users/myuser/Documents/workspaces/templates/Test_template_exported.xlsx"

 

Next, I uploaded the file I had just downloaded to temp-contents:

 curl --fail-with-body --silent --show-error \
--request POST \
"https://myhost.xx.qlikcloud.com/api/v1/temp-contents?filename=test_template.xlsx" \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" \
--data-binary "@/Users/myuser/Documents/workspaces/templates/Test_template_exported.xlsx" \
--dump-header upload-headers.txt \
--output /dev/null

 

And finally, I associated it with the cloned app:

  curl --fail-with-body --silent --show-error \
  --request POST \
  "https://myhost.xx.qlikcloud.com/api/v1/report-templates" \
  -H "Authorization: Bearer <TOKEN>" \
  -H "Content-Type: application/json" \
  --data "{
    \"name\": \"template_clone\",
    \"description\": \"Cloned template\",
    \"temporaryContentId\": \"xxxxxxxxxxxxxxxxx\",
    \"sourceAppId\": \"xxxxxx-xxx-xxxx-xxxx-xxxxxxxxx\",
    \"sourceAppAction\": \"replace\"
  }"

temporaryContentId comes from upload-headers.txt

cristian_dalsanto
Partner - Contributor III
Partner - Contributor III
Author

Thanks @Øystein_Kolsrud 

This was exactly what I was looking for!

Unfortunately, I wasn't able to find the correct configuration to set in the documentation.

Thanks to the code you provided, I was able to successfully enable On-demand reporting.

Thanks again for your help!