Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am having some trouble with the qlik.exe cli
I should be able to make a call like : qlik raw put $pathtoAPI --body-values $hashtable
I cannot make this call. I get an error every time. I will share my code.
We can use the Data Connections API as an example: Data connections | Qlik Developer Portal
#Variables I use
$APITenant = "https://thenameofmyqliktenant.com"
$APIEndpoint = "/v1/data-connections"
$apikey = "secretkey123"
$TargetDataConnection = $APIEndpoint+"/"+{qID of the targeted Data Connection}
## Calls (keep in mind my qlik context is already set)
qlik raw get $TargetDataConnection | Convertfrom-json
## I now build a form as a hashtable for the body call later
$hashtable = @{}
## End of script for now.
According to the Data-Connections API, I should be to build a hash table (key=value, which that colde '@{}' does) with all of the required data listed in the under the 'request' for the 'put' command on the API web page. I include all of those in the $hashtable, and make the call like this:
qlik raw put $TargetDataConnection --body-value $hashtable
This call doesn't work.
Before I share the error, I wanted to share the qlik --help for this call
Usage:
qlik raw <get/put/patch/post/delete> v1/url [flags]
Examples:
qlik raw get v1/items --query name=ImportantApp
Flags:
--body string The content of the body as a string
--body-file string A file path pointing to a file
containing the body of the http request
--body-values stringToString A set of key=value pairs that well be
compiled into a json object. A dot
(.) inside the key is used to
traverse into nested objects. The key
suffixes :bool or :number can be
appended to the key to inject the
value into the json structure as
boolean or number respectively.
(default [])
The error I get when using a hashtable is:
C:\QlikCLI\qlik.exe : Error: invalid argument "System.Collections.Hashtable" for "--body-values" flag: System.Collections.Hashtable must be formatted as
key=value
At line:1 char:1
+ C:\QlikCLI\qlik.exe raw PUT $APIDCEndpoint --body-values $hashtable --ver ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Error: invalid ...ed as key=value:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
## I am pretty sure my hashtable is created properly.
The error I get if I don't use a hashtable is:
Error: {
"errors": [
{
"code": "DCERROR-0010",
"title": "Bad or invalid request",
"status": 400,
"detail": "Binding body failed: invalid character '@' looking for beginning of value"
}
],
"traceId": "0000000000000000ce63fdcb7bf3d0aa"
}
Someone Help!! Thanks
3: Qlik-CLI (qlik.exe) is written in golang the Standard Library, only supports UTF8 & UTF16 unicode/utf8
Windows defaults to UTF8-BOM
so unless you add a 3rd party package or write the code to detect and support UTF8-BOM it will have issues.
Using Qlik-CLI on Linux or MacOS that use UTF8 by default you would not run into this... nor need the extra code to support it...
So probably less a bug and more a opportunity....
FWIW I add this to my PowerShell scripts when I need to write UTF8 files Write-UTF8File.ps1
I owe you a like a coffee, or a beer, or a coffeebeer, or something. Thanks for all the help!