Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
chriscammers
Partner - Specialist
Partner - Specialist

Editing users with qlik-cli

Following the documentation for editing users in the qlik-cli we are getting errors when attempting to edit a user

 

https://qlik.dev/toolkits/qlik-cli/user/user-edit/

 

We've tried a bunch of different variations for changing the user email address so we can migrate to a new identity provider.

 

 

//If we enter 
qlik user edit <userid>

//then a notepad window pops up and with the user content
//which we can edit without issue but the help for the command 
//shows how to use a --body flag but no matter how we code 
//that one we get an error saying that the flag --body does
//not exist



//Here is the text from the command help



qlik user edit <userId> --body '[{"op":"replace","path":"/name","value":<value>}]'

 

 

 

Does anybody have any suggestion for this syntax 

 

Labels (1)
  • SaaS

7 Replies
Levi_Turner
Employee
Employee

The default way that I'd perform this work is without using the edit command. Example which works:

qlik user patch Ua1GHmCCt-qoUM9ESpi8-tFY86kl5pCT --body "[{""op"":""replace"",""path"":""/email"",""value"":""unicorn@corp.example""}]"

* Note: I am using PowerShell and Windows. My memory is that you need to escape with \ rather than an additional double quote (") when using my Mac.

That being said, the qlik user edit works for me (qlik-cli version 2.24.0). My work-flow is:

- qlik user edit Ua1GHmCCt-qoUM9ESpi8-tFY86kl5pCT --> Notepad opens

- Edit the field & Save the file (Ctrl+S)

- Verify the changes

But overall, the qlik user patch route is the path I'd take as it permits you to do the operations programmatically without user interaction.

Leigh_Kennedy
Employee
Employee

Here are 2 examples that works on a mac:

qlik raw patch v1/users/ONF-aLeBJReJwug3C8-pWDij0WiLrMQJ --body '[{"op":"replace","path":"/name","value":"James Bond"}]'

 

qlik raw patch v1/users/ONF-aLeBJReJwug3C8-pWDij0WiLrMQJ --body "[{\"op\":\"replace\",\"path\":\"/name\",\"value\":\"Jim Bond\"}]"

 

As to your question, I think there is a doc bug with the "--body" flag, so we will raise this internally.

chriscammers
Partner - Specialist
Partner - Specialist
Author

Just the man I was hoping would respond!!! Thanks Levi!

We were looking at Patch as the next option. Hopefully this will get us a little further along.

 

Thanks

chriscammers
Partner - Specialist
Partner - Specialist
Author

We got around to trying it and we're still getting the error from the body I think our syntax resembles what you have above.

Levi_Turner
Employee
Employee

Since you're executing this in PowerShell on Windows, I would use this style of body.

qlik user patch Ua1GHmCCt-qoUM9ESpi8-tFY86kl5pCT --body "[{""op"":""replace"",""path"":""/email"",""value"":""unicorn@corp.example""}]"

We're using double double-quotes ("") to escape. The back-slash escaping is needed when using bash (MacOS / Linux).

chriscammers
Partner - Specialist
Partner - Specialist
Author

Leigh,

Did you raise this as a bug?? We tried a bunch of variations and could not properly form the body in the cli. In the effort to keep our project moving we did create an automation that will loop over a list of email addresses and then update the email to a new one via the raw api call block. This will allow us to change the active IDP so the users will keep their content.

 

Thanks

Leigh_Kennedy
Employee
Employee

I did pass it on, but it's only the docs that I think are wrong.  Both @Levi_Turner and my approaches work.  if you add '--verbose' to your command you should see the JSON as it is passed. See my example (Look at the. 'PAYLOAD' section): 

 

 

 

qlik raw patch v1/users/ONF-aLeBJReJwug3C8-pWDij0WiLrMQJ --body "[{\"op\":\"replace\",\"path\":\"/name\",\"value\":\"Jim Bond\"}]" --verbose
Server-type not set, guessing "cloud"
PATCH https://lkn-qlkaccount.ap.qlikcloud.com/api/v1/users/ONF-aLeBJReJwug3C8-pWDij0WiLrMQJ
* Establishing connection to: lkn-qlkaccount.ap.qlikcloud.com:443
* TLS Handshake started
* TLS Handshake done (47ms), version: TLS v1.3
* Connection established (135ms)
> Host: lkn-qlkaccount.ap.qlikcloud.com
> User-Agent: qlik-cli/2.25.0 (darwin) raw
> Transfer-Encoding: chunked
> Authorization: Bearer **omitted**
> Content-Type: application/json
> Referer: https://lkn-qlkaccount.ap.qlikcloud.com
> Accept-Encoding: gzip
PAYLOAD:
[
  {
    "op": "replace",
    "path": "/name",
    "value": "Jim Bond"
  }
]
< Cache-Control: no-store
< Connection: keep-alive
< Date: Mon, 01 Jul 2024 22:46:22 GMT
< Pragma: no-cache
< Set-Cookie: **omitted**
< Strict-Transport-Security: max-age=15724800; includeSubDomains
Response time: 343ms
Status: 204 No Content