Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
moritzreinhard2
Partner - Contributor III
Partner - Contributor III

QRS API move app

Hi,

I cannot find an API for moving a published app to another stream. In QRS API, you can copy an app, publish the copied app and delete the old app. However, this is not acceptable for us because the app_id changes within this process.

I am also open for other API (Engine API, etc.) as long as I can execute them from Javascript.

Any ideas? Thanks a lot!!

Cheers

Moritz

 

Labels (1)
1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

The new values goes in the body of the PUT request. So pseudo-code something like this:

var appInfo = GET('/qrs/app/046b6c7f-0b8a-43b9-b35d-6489e6daee91');
appInfo.stream.id = '5434956a-0008-4e69-bf01-dc38564b6fd7';
PUT('/qrs/app/046b6c7f-0b8a-43b9-b35d-6489e6daee91', appInfo);

 

View solution in original post

6 Replies
Levi_Turner
Employee
Employee

Some of this is version dependent but if you're on something modern then either should work. There are technically two endpoints which can use both of which I have examples using the Qlik-Cli-Windows PowerShell library:

https://github.com/levi-turner/QlikSenseScripts/blob/master/qs-cli/qs-cli-move_app-hub_method.ps1

https://github.com/levi-turner/QlikSenseScripts/blob/master/qs-cli/qs-cli-move_app-qmc_method.ps1

I personally prefer the QMC method since it's more extendable since it can leverage certificates for auth.

Cheers

Øystein_Kolsrud
Employee
Employee

I think it's just a question of changing the "stream.id" property of the app. So do a GET on this:

https://help.qlik.com/en-US/sense-developer/September2020/APIs/RepositoryServiceAPI/index.html?page=...

Change stream.id to the ID of the destination stream, and the do a PUT on this:

https://help.qlik.com/en-US/sense-developer/September2020/APIs/RepositoryServiceAPI/index.html?page=...

moritzreinhard2
Partner - Contributor III
Partner - Contributor III
Author

Hi Levi_Turner,

that sounds good. However I have to execute it from Javascript, and this qlik-cli is from command line. Maybe there is a way to write command line commands in javascript but that it seems to me to cumbersome.

Thanks!

 

moritzreinhard2
Partner - Contributor III
Partner - Contributor III
Author

Hi Yko,

probably this is exactly what I want. But how to change the stream.id of an app exactly.  I only see 

put /qrs/app/046b6c7f-0b8a-43b9-b35d-6489e6daee91

Is it something like

put /qrs/app/046b6c7f-0b8a-43b9-b35d-6489e6daee91&stream.id=5434956a-0008-4e69-bf01-dc38564b6fd7     ???

I don't find an example. Could you give me an example? Thanks!

Cheers

Moritz

Øystein_Kolsrud
Employee
Employee

The new values goes in the body of the PUT request. So pseudo-code something like this:

var appInfo = GET('/qrs/app/046b6c7f-0b8a-43b9-b35d-6489e6daee91');
appInfo.stream.id = '5434956a-0008-4e69-bf01-dc38564b6fd7';
PUT('/qrs/app/046b6c7f-0b8a-43b9-b35d-6489e6daee91', appInfo);

 

moritzreinhard2
Partner - Contributor III
Partner - Contributor III
Author

That works! Here the javascript code I used:

 

 

var httpRequest6 = new XMLHttpRequest();
httpRequest6.open("GET", baseUrl+'/qrs/app/'+AppID_Target+'?xrfkey=abcdefghijklmnop', true);
httpRequest6.setRequestHeader("x-Qlik-Xrfkey", xrfkey);
httpRequest6.send();
httpRequest6.onload= function() {
var qrsResponse = JSON.parse(httpRequest6.response);
qrsResponse.stream.id='83e32f65-b361-48f9-905c-befab5f49993';
var httpRequest7 = new XMLHttpRequest();
httpRequest7.open("PUT", baseUrl+'/qrs/app/'+AppID_Target+'?xrfkey=abcdefghijklmnop', true);
httpRequest7.setRequestHeader("x-Qlik-Xrfkey", xrfkey);
httpRequest7.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
httpRequest7.send( JSON.stringify(qrsResponse) );
httpRequest7.onload= function() {
  window.alert(httpRequest7.response);
};