Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
eazoury
Contributor
Contributor

Post database script to app using api

Hi all ,

We are trying to create templates so end users can base their work on. We want him  to choose between a set of scripts already written . Is their anyway to post a whole script to an  existing app using  api request ? We are using .net to develop the framework.

1 Solution

Accepted Solutions
NadiaB
Support
Support

Hi @eazoury 

You probably could use ODAG if the only that changes is the where clause ,as the odag will segreate according to selections

Qlik Sense in 60 - On Demand App Generation (ODAG)
https://www.youtube.com/watch?v=Ft3I00-g4H4

But if what you want is to have different scritps, you proabaly will need to duplicate the app and change the script

Copy App:

https://help.qlik.com/en-US/sense-developer/May2021/Subsystems/RepositoryServiceAPI/Content/Sense_Re...

https://help.qlik.com/en-US/sense-developer/February2020/APIs/EngineAPI/services-Global-CopyApp.html

Set Script

https://help.qlik.com/en-US/sense-developer/April2020/APIs/EngineAPI/services-Doc-SetScript.html

You will probably need to change the owner if the API is not triggered with the user that needs access to the app, and also you will need to trigger a reload 

https://help.qlik.com/en-US/sense-developer/May2021/Subsystems/EngineAPI/Content/Sense_EngineAPI/Cre...

Hope it helps.

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm

View solution in original post

5 Replies
NadiaB
Support
Support

Hi @eazoury 

You probably could use ODAG if the only that changes is the where clause ,as the odag will segreate according to selections

Qlik Sense in 60 - On Demand App Generation (ODAG)
https://www.youtube.com/watch?v=Ft3I00-g4H4

But if what you want is to have different scritps, you proabaly will need to duplicate the app and change the script

Copy App:

https://help.qlik.com/en-US/sense-developer/May2021/Subsystems/RepositoryServiceAPI/Content/Sense_Re...

https://help.qlik.com/en-US/sense-developer/February2020/APIs/EngineAPI/services-Global-CopyApp.html

Set Script

https://help.qlik.com/en-US/sense-developer/April2020/APIs/EngineAPI/services-Doc-SetScript.html

You will probably need to change the owner if the API is not triggered with the user that needs access to the app, and also you will need to trigger a reload 

https://help.qlik.com/en-US/sense-developer/May2021/Subsystems/EngineAPI/Content/Sense_EngineAPI/Cre...

Hope it helps.

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

eazoury
Contributor
Contributor
Author

Hi again,

Thanks for your reply it was very helpful.

I tried using the qlik engine and wrote some code here is how it looks like :

public Stream setScript(string appId , string script)
{
location.VirtualProxyPath = "https://sensetst:4747/engineapi/";

location.AsStaticHeaderUserViaProxyAsync("FR-MUREX-COM", "stat-hdr",false, false);

try
{
using (var app = location.App(location.AppWithId(appId), randomSession, null, true))// Location specified in Accessing
{
app.SetScript(script);
byte[] byteArray = Encoding.ASCII.GetBytes("ok");
return new MemoryStream(byteArray);
}
}
catch (MethodInvocationException e)
{
byte[] byteArray = Encoding.ASCII.GetBytes("Could not open app: " + Environment.NewLine + e.InvocationError.Message);
return new MemoryStream(byteArray);
}
catch (TimeoutException e)
{
byte[] byteArray = Encoding.ASCII.GetBytes("Timeout for: " + Environment.NewLine + e.Message);
return new MemoryStream(byteArray);
}
}

However opening the app  : location.appwithid() is giving me a time out exception "Method "QTProduct" timed out" 

Could it be a problem with the proxy configuration  ?

eazoury_0-1630505319999.png

 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you connect via the Proxy

location.AsStaticHeaderUserViaProxyAsync

then your URI should be the proxy path -- same URL you use in the browser -- not the engine port. 

-Rob

NadiaB
Support
Support

Hi @eazoury 

 

By any chance have you seen this already ?

 

https://community.qlik.com/t5/Integration-Extension-APIs/First-steps-in-Qlik-Sense-NET-SDK-saga-What...

 

Kind Regards,

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm