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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
TejalJadhav92
Partner - Contributor II
Partner - Contributor II

to automate exporting Qlik SaaS app scripts using qlik saas and the Qlik REST APIs

Hi Team,

I am running the below script. But, I am getting below error. Could some one help me on the below error code?

 

AppList_temp:

LOAD [id] as AppID,
[name] as AppName,
[resourceType] as AppResourceType,
[ownerId] as AppOwnerId
FROM [lib://DataFiles/App_ID_NAME.xlsx]
(ooxml, embedded labels, table is Sheet1);

 

AppList:
NOCONCATENATE
LOAD *
RESIDENT AppList_temp
WHERE AppResourceType = 'app'; // Or whatever your app type is consistently named

DROP TABLE AppList_temp;

TRACE Found $(NoOfRows('AppList')) applications.;

AppScriptsData:
LOAD
'' as AppID,
'' as AppName,
'' as ScriptFileName,
'' as Status
AUTOGENERATE 0;


LET vNumApps = NoOfRows('AppList');

IF $(vNumApps) > 0 THEN
FOR i = 0 TO $(vNumApps) - 1
LET vAppID = Peek('AppID', $(i), 'AppList');
LET vAppName = Peek('AppName', $(i), 'AppList');

// Sanitize AppName for filename (basic sanitization)
LET vSafeAppName = PurgeChar(Replace(Trim('$(vAppName)'), ' ', '_'), '/\:*?"<>|');
IF Len(Trim($(vSafeAppName))) = 0 THEN
LET vSafeAppName = 'UnnamedApp_$(vAppID)';
ENDIF;

LET vScriptFileName = '$(vSafeAppName)_$(vAppID).qvs';
LET vFullExportPath = '$(vExportPath)$(vScriptFileName)';

TRACE Processing App: '$(vAppName)' (ID: $(vAppID));

LET vScriptUrl = '$(vQlikCloudTenant)/dataloadeditor/apps/$(vAppID)/script';


AppScript_temp:
LOAD
[script] as AppScriptContent
FROM [$(vScriptUrl)]
(URL IS [$(vScriptUrl)], HTTPHEADER "Authorization" "Bearer $(vApiKey)", 

TejalJadhav92_0-1746525840824.png

 

Labels (2)
1 Reply
marksouzacosta

Hi @TejalJadhav92,

Not sure if you can use that vScriptUrl you setup. I never used anything like that.
In any case, you could try to use https://qlik.dev/apis/rest/apps/#get-v1-apps-appId-scripts and https://qlik.dev/apis/rest/apps/#get-v1-apps-appId-scripts-id endpoints. You have to setup REST Connection(s) and play around to get the correct Script ID.

Qlik Application Automation can be also an alternative, depending on how you would like to store the QVS script. Create a new Qlik Application Automation and search for "Commit an app to GitHub" template. It will help to understand how you can extract and save as a file the Load Script.

Please let me know if that makes sense to you and if we can help on anything else.

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com