Skip to content

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:

Terminal window
qlik user ls

Then, 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.com
  • auth0|8d2626094d70ac63e5492d2eac494197adac5ec3755b044b79417c4e2ca43e76
  • qlikbot\\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.

Note

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.

Terminal window
qlik user patch <userId> --file patch.json

Example 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 Content
Empty response body
Tip

If the payload doesn’t look correct, adjust your escaping and run the command again.

Was this page helpful?