Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
hvdbunte
Partner - Contributor III

edit script load editor with .net SDK

Hi,

We started using the .net SDK in combination with the Qlik-Cli for Windows version for deploying apps to multiple streams.
For every stream we would like to change some variables in the Data load editor. Is that possible with the SDK? I found some options for changing the script with the engine JSON api but not with the SDK.

We have these 3 variables that we use to connect databases, we would like to change for every stream:

let CustomerName = 'CustomerA'
let DWH_CustomerName = 'DWH_CustomerA'
let Source_CustomerName = 'Source_CustomerA'

Would it be possible to search and replace these variable values in the load script?

Kind Regards

Labels (1)
22 Replies
michasiuk
Creator

@Marc 

Hi Mark I have bee working through your solution closely but am running into some websocket issues. The error that I keep getting with my code is the following.

Exception calling "GetAppIdentifiers" with "1" argument(s): "The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived'"
At D:\QLIK\Development\PowerShell\LoadScriptAudit2.ps1:42 char:1
+ $AppIdentifiers = [Qlik.Engine.LocationExtensions]::GetAppIdentifiers($Location)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebSocketException

I'm not sure what is causing it. I have gone through the QMC and made sure that the virtual proxy is enabled and white listed but I still keep getting the same error. I have put up a community post see link below but haven't managed to get a useful response to date. So I am still not sure what is causing the issue.

https://community.qlik.com/t5/Connectivity-Data-Prep/Web-sockets-connectivity-issue-net-SDK/m-p/1819...

michasiuk
Creator

Just a quick note I can get the Qlik-Cli to work successfully but I cannot get this to work successfully

hvdbunte
Partner - Contributor III
Author

@michasiukI am not sure if this is still helpful but we are using different code to connect to qlik sense:

 $uri = "wss://$($computerName):$($computerPort)"

 Write-Verbose "uri: $uri"
   $location = [Qlik.Engine.Location]::FromUri($uri)
[Qlik.Engine.LocationExtensions]::AsDirectConnection($location,$userDirectory,$userName)

        # get the app's appIdentifier 
	    $appIdentifier = [Qlik.Engine.LocationExtensions]::AppWithIdOrDefault($location, $id)

The $id variable is the app id.

Hope this helps.

michasiuk
Creator

Thanks I'll try this and see what happens. The only question that I would like to ask is what should the variable $id be set to in the line. 

$appIdentifier = [Qlik.Engine.LocationExtensions]::AppWithIdOrDefault($location, $id)

 

michasiuk
Creator

modified the script slightly changed the line:

$appIdentifier = [Qlik.Engine.LocationExtensions]::AppWithIdOrDefault($location, $id)

to 

$appIdentifier = [Qlik.Engine.LocationExtensions]::AppWithIdOrDefault($location)

But getting the following error: I suspect that it's a certificate error not sure how to use certificates in the connection.

Exception calling "GetAppIdentifiers" with "1" argument(s): "Value cannot be null.
Parameter name: certificates"
At D:\QlikNprinting\PowerShell\Script\TestConnect.ps1:25 char:1
+ $AppIdentifiers = [Qlik.Engine.LocationExtensions]::GetAppIdentifiers($Location) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException

LDR
Creator II

Hi @Marc 

I have to say that I'm a beginner using QlikSense.NetSDK so probably the issue I found is because my lack of knowledge.

I'm running the following code:

add-type -path "D:\Qlik Powershell\newtonsoft.json.6.0.1\lib\net45\Newtonsoft.Json.dll"
add-type -path "D:\Qlik Powershell\qliksense.netsdk.16.9.0\lib\net452\Qlik.Engine.dll"
add-type -path "D:\Qlik Powershell\qliksense.netsdk.16.9.0\lib\net452\Qlik.Sense.JsonRpc.dll"
add-type -path "D:\Qlik Powershell\qliksense.netsdk.16.9.0\lib\net452\Qlik.Sense.Client.dll"

$SenseServerURL = "https://qliktest"
$QlikCeredentials = Get-Credential
$ProxyUsesSSL = $true
$TrustAllCerts = $true

#Create the Location Object
$Location = [Qlik.Engine.Location]::FromUri($SenseServerURL)

#Establish a Authenticated Session to the Location.
[Qlik.Engine.LocationExtensions]::AsNtlmUserViaProxy($Location,$ProxyUsesSSL,$QlikCeredentials,$TrustAllCerts)

 

Powershell shows me the following error:

Method invocation failed because [Qlik.Engine.LocationExtensions] does not contain a method named 'AsNtlmUserViaProxy'.
At line:15 char:1
+ [Qlik.Engine.LocationExtensions]::AsNtlmUserViaProxy($Location,$Proxy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Does anybody know what I'm doing wrongly?

Thanks

LDR
Creator II

I loaded the same dll releases you put and everything worked for me.

Is it possible to receive the answer in JSON format?

Thanks

Marc
Employee

The Method AsNtlmUserViaProxy is no longer an extension method.

so you would use

$Location.AsNtlmUserViaProxy($QlikCeredentials,$TrustAllCerts)

Marc
Employee

?
{
ErrorCause: "The Method AsNtlmUserViaProxy is no longer an extension method.",
Fix: "$Location.AsNtlmUserViaProxy($QlikCeredentials,$TrustAllCerts)"
}