Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm very new to the Qlik Sense SDK but fairly familiar with PowerShell. We net to change the themes and images in a number of Apps on our Qlik Sense installation. Basically rebrand the Apps. To do this manually is a lot of work, so I have been looking into the .NET SDK. I have managed to figure how to modify the load script and rename sheets in an App using PowerShell and the SDK. I'm not even sure if INxQrsEngineService is what I should be using because I'm so new to this and I'm the the documentation a bit ambiguous. an excerpt form the PowerShell that I'm using is listed below:
Connect-Qlik -Computername $QlikSenseServer -Certificate $cert -Username "$($UserDirectory)\$($UserID)"
$Location = [Qlik.Engine.Location]::FromUri($SenseServerURL)
$Credentials = [Qlik.Engine.LocationExtensions]::AsDirectConnection($Location, $UserDirectory,$UserID,$extendedSecurityEnvironment,$certificateValidation,$cert)
$QEAppIdentifier = [Qlik.Engine.LocationExtensions]::AppWithId($Location, $TestAppID)
$QEApp = [Qlik.Engine.LocationExtensions]::App($Location, $QEAppIdentifier)
$QEAppSettings = [Qlik.Engine.INxQrsEngineService]::Settings($QEApp)
I have been referring to the following documentation: https://help.qlik.com/en-US/sense-developer/May2021/Subsystems/NetSDKAPIref/Content/Qlik.Engine.INxQ... which lists name and settings.
I promptly got the following error.
Method invocation failed because [Qlik.Engine.INxQrsEngineService] does not contain a method named 'settings'.
At E:\Qlik\PowerShell\Script\ListSheets.ps1:54 char:1
+ $QEAppSettings = [Qlik.Engine.INxQrsEngineService]::Settings($QEApp)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
I managed to realize that it was a property not a method.
When I ran the following code:
$QSINxQrsEngineService = [Qlik.Engine.INxQrsEngineService]
$QSINxQrsEngineService
I got the output listed below which gave me no reference to name or settings as listed in the documentation so I'm basically lost in trying to find a solution to my problem:
Module : Qlik.Engine.dll
Assembly : Qlik.Engine, Version=15.4.2.0, Culture=neutral, PublicKeyToken=1a848309662c81e5
TypeHandle : System.RuntimeTypeHandle
DeclaringMethod :
BaseType :
UnderlyingSystemType : Qlik.Engine.INxQrsEngineService
FullName : Qlik.Engine.INxQrsEngineService
AssemblyQualifiedName : Qlik.Engine.INxQrsEngineService, Qlik.Engine, Version=15.4.2.0, Culture=neutral, PublicKeyToken=1a848309662c81e5
Namespace : Qlik.Engine
GUID : f30e8025-64b1-36bf-b78b-2e46f03b29a6
IsEnum : False
GenericParameterAttributes :
IsSecurityCritical : True
IsSecuritySafeCritical : False
IsSecurityTransparent : False
IsGenericTypeDefinition : False
IsGenericParameter : False
GenericParameterPosition :
IsGenericType : False
IsConstructedGenericType : False
ContainsGenericParameters : False
StructLayoutAttribute :
Name : INxQrsEngineService
MemberType : TypeInfo
DeclaringType :
ReflectedType :
MetadataToken : 33555105
GenericTypeParameters : {}
DeclaredConstructors : {}
DeclaredEvents : {}
DeclaredFields : {}
DeclaredMembers : {System.String get_name(), Void set_name(System.String), Qlik.Engine.NxQrsEngineSettings get_settings(), Void set_settings(Qlik.Engine.NxQrsEngineSettings)...}
DeclaredMethods : {System.String get_name(), Void set_name(System.String), Qlik.Engine.NxQrsEngineSettings get_settings(), Void set_settings(Qlik.Engine.NxQrsEngineSettings)}
DeclaredNestedTypes : {}
DeclaredProperties : {System.String name, Qlik.Engine.NxQrsEngineSettings settings}
ImplementedInterfaces : {Qlik.Engine.IAbstractStructure}
TypeInitializer :
IsNested : False
Attributes : AutoLayout, AnsiClass, Class, Public, ClassSemanticsMask, Abstract
IsVisible : True
IsNotPublic : False
IsPublic : True
IsNestedPublic : False
IsNestedPrivate : False
IsNestedFamily : False
IsNestedAssembly : False
IsNestedFamANDAssem : False
IsNestedFamORAssem : False
IsAutoLayout : True
IsLayoutSequential : False
IsExplicitLayout : False
IsClass : False
IsInterface : True
IsValueType : False
IsAbstract : True
IsSealed : False
IsSpecialName : False
IsImport : False
IsSerializable : False
IsAnsiClass : True
IsUnicodeClass : False
IsAutoClass : False
IsArray : False
IsByRef : False
IsPointer : False
IsPrimitive : False
IsCOMObject : False
HasElementType : False
IsContextful : False
IsMarshalByRef : False
GenericTypeArguments : {}
CustomAttributes : {[Newtonsoft.Json.JsonObjectAttribute()], [Qlik.Engine.ValueClassAttribute()]}
For the App Thumbnail, we can use the QRS API's
$QlikApp = Get-QlikApp -id $TestAppID -raw
$QlikApp.thumbnail = '/content/default/file.png'
Invoke-QlikPut "/qrs/app/$($QlikApp.id)" -body $($QlikApp|ConvertTo-Json -Depth 10)
to update the AppProperties,
$QEApp = [Qlik.Engine.LocationExtensions]::App($Location, $QEAppIdentifier, $Session, $noData)
$AppInfo = $QEApp.GetAllInfos()
$AppProps = $AppInfo | Where-Object{
$_.type -eq 'appprops'
}
$QEAppProps = $QEApp.GetGenericObject($AppProps.Id)
$AppProperties = $QEAppProps.GetProperties()
# Generic Methods are a pain...
$AppPropObj = $AppProperties.GetType().GetMethod("As").MakeGenericMethod([Qlik.Sense.Client.AppPropertiesObjectProperties]).Invoke($AppProperties,$null)
#Once we have the AppPropertiesObject We can set the properties such as Theme and colours
$AppPropObj.Theme=$SelectedTheme
$AppPropObj.SheetTitleBgColor = '#8e477d'
$AppPropObj.SheetTitleColor = '#4477aa'
$AppPropObj.SheetLogoThumbnail.StaticContentUrlDef.Url = '/appcontent/c5e963ad-9497-4ca6-8d10-e6ca500b58eb/Icon_Chart_grey.png'
$QEAppProps.SetProperties($AppPropObj)
$QEApp.SaveObjects()
$QEApp.Dispose()
Hello,
Thank you for this post
I can't connect with Connect-Qlik -Computername $QlikSenseServer -TrustAllCerts -Username "$($UserDirectory)\$($UserID)"
I have an error related to the certificate, maybe you can help me?
I'm using Qlik sense enterprise, and I have this feedback : Invoke-RestMethod powershell: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Thanks in advance for your help
That would be because to use the parameter UserName you must also supply the Qlik client certificate.
$QlikClientCertificate = Get-ChildItem Cert:\CurrentUser\My\ | Where-Object {
$_.Subject -eq "CN=QlikClient"
}
Connect-Qlik -Computername $QlikSenseServer -TrustAllCerts -Username "$($UserDirectory)\$($UserID)" -Certificate $QlikClientCertificate