Handle character escaping in qlik-cli
Proper character escaping is essential for working with qlik-cli, especially when passing JSON payloads or filter expressions.
Escaping syntax depends primarily on your shell and, for PowerShell, on the PowerShell version.
This guide covers the --filter and --body options.
Prerequisites
- qlik-cli installed and configured
- A context set up for authentication
- Familiarity with JSON and OData syntax
Escape quotes in the --filter option
The --filter option uses OData syntax.
Example expression: subject eq "user@example.com"
All examples in the Filter examples section produce this expression.
When filtering by subject, retrieve the subject value:
qlik user lsThen, copy the subject value exactly as returned and escape it according to your shell.
The subject format varies depending on the identity type. Examples include:
user@example.comauth0|8d2626094d70ac63e5492d2eac494197adac5ec3755b044b79417c4e2ca43e76qlikbot\\fbf637de84ab48c1b8da767a9025a714
Filter examples
Escape quotes in the --body option
When using the --body option with JSON payloads in commands like qlik user patch or qlik raw patch,
proper escaping rules depend on your shell.
The qlik user patch and qlik raw patch commands expect a user ID, for example 696el7cb6df8986cde32kia6,
not a subject value.
To get the user ID, run qlik user ls.
Body examples
Avoid escaping issues
For scripts and more complex payloads, using a file is often easier than inline escaping.
qlik user patch <userId> --file patch.jsonExample patch.json file:
[ { "op": "replace", "path": "/name", "value": "Jane Doe" }]This approach works reliably across shells.
Verify your escaping with --verbose
If a command fails or you’re unsure about your syntax, use the --verbose option to see the actual payload being sent
to the server.
This helps verify that your escaping is correct.
The output will show the formatted JSON payload and the server response, for example:
PATCH https://<tenant>/api/v1/users/<userId>...PAYLOAD:[ { "op": "replace", "path": "/name", "value": "Jane Doe" }]...Status: 204 No ContentEmpty response bodyIf the payload doesn’t look correct, adjust your escaping and run the command again.