Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have come-up with below script, however it is keep loading but nit giving me any results.
Can you please let me know if anything is missing in my script.
Script:
function GetXrfKey() {
$alphabet = $Null; For ($a=97;$a -le 122;$a++) { $alphabet += ,[char][byte]$a }
For ($loop=1; $loop -le 16; $loop++) {
$key += ($alphabet | Get-Random)
}
return $key
}
$xrfKey = GetXrfKey
$cert=Get-ChildItem -Path "cert:\CurrentUser\My" | where {$_.Subject -like "*QlikClient*"}
$url="http://127.0.0.1:4747/qrs/app/about?xrefkey=" + $xrfKey
$hrds=@{"x-qlik-xrfkey"=$xrfKey
"X-Qlik-User"='UserDirectory=DESKTOP-A7R270Q;UserId=GIS-11'}
Invoke-RestMethod -Method "get" -Uri $url -CertificateThumbprint $cert.Thumbprint -Headers $hrds
Hey Rangam,
I am bit confused by some of the choices that were made here. Here's revamped code which is running clean:
function GetXrfKey() {
$alphabet = $Null; For ($a=97;$a -le 122;$a++) { $alphabet += ,[char][byte]$a }
For ($loop=1; $loop -le 16; $loop++) {
$key += ($alphabet | Get-Random)
}
return $key
}
$xrfKey = GetXrfKey
$cert=Get-ChildItem -Path "cert:\CurrentUser\My" | where {$_.Subject -like "*QlikClient*"}
$Data = Get-Content C:\ProgramData\Qlik\Sense\Host.cfg
$FQDN = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($($Data)))
$url="https://$($FQDN):4242/qrs/about?xrfkey=" + $xrfKey
$hdrs = @{}
$hdrs.Add("x-qlik-xrfkey", $xrfKey)
$hdrs.Add("X-Qlik-User", "UserDirectory=INTERNAL; UserId=sa_api")
Invoke-RestMethod -Method "get" -Uri $url -CertificateThumbprint $cert.Thumbprint -Headers $hdrs
Some notes:
Hope that helps.
I am quite new to JS, but shouldn't this line:
$xrfKey = GetXrfKey
be changed to:
$xrfKey = GetXrfKey();
So that way you call the function?
Thanks for request, I am getting the expected output under $xrfKey even without ().
Well I am not good enough in JS to debug this, but I would change this topic from:
Assumed Answered.
And I would indent the code correctly, so it's easier to read for the people that do know enough JS.
My only other suggestion would be to use the debugger / console.log() and just go through it step by step, but you probably already did that.
Sorry I couldn't help any further!
No Problem, but I found an answer for this query wherein I am not passing the content type in my invoke request.
Helping hand is always helpful, no need to apologize ![]()
Thank you very much for stepping forward and helping me
...
Hey Rangam,
I am bit confused by some of the choices that were made here. Here's revamped code which is running clean:
function GetXrfKey() {
$alphabet = $Null; For ($a=97;$a -le 122;$a++) { $alphabet += ,[char][byte]$a }
For ($loop=1; $loop -le 16; $loop++) {
$key += ($alphabet | Get-Random)
}
return $key
}
$xrfKey = GetXrfKey
$cert=Get-ChildItem -Path "cert:\CurrentUser\My" | where {$_.Subject -like "*QlikClient*"}
$Data = Get-Content C:\ProgramData\Qlik\Sense\Host.cfg
$FQDN = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($($Data)))
$url="https://$($FQDN):4242/qrs/about?xrfkey=" + $xrfKey
$hdrs = @{}
$hdrs.Add("x-qlik-xrfkey", $xrfKey)
$hdrs.Add("X-Qlik-User", "UserDirectory=INTERNAL; UserId=sa_api")
Invoke-RestMethod -Method "get" -Uri $url -CertificateThumbprint $cert.Thumbprint -Headers $hdrs
Some notes:
Hope that helps.