I'm trying to set a user's manager via the CLI's gc users update command. Unfortunately, no matter what I pass in as a parameter, the manager isn't getting updated.
I tried using userId, email and full name, as well as (just in case), the object normally returned by the users get command.
The API reference only says manager is of type string, but nothing else (this is something I find extremely frustrating BTW, why are there never any request parameter examples provided?)
id : 56698316-013e-42ea-n1a9-8824314d523u
name : John Smith
department : Support
email : john.smith@company.com
addresses : {}
state : active
title : Customer Support Specialist
username : john.smith@company.com
manager : 1e427x8d-cdxf-4b79-4c06-a37528d2p4ev
version : 1
locations : {@{notes=; locationDefinition=}}
groups : {}
acdAutoAnswer : False
Are you getting an error when execute the command? Have you confirmed $newUserId corresponds to the id of the user you are updating?
I also noticed an id field in your user object, the request body for PATCH /api/v2/users/{userId} does not contain an id field, the id of the user is only given as a request parameter as you have done.
I would also suggest only including fields you want to update since the endpoint is a PATCH.
Please try to remove the state property in your $newUser.
This PATCH /api/v2/users/{userId} endpoint is a bit specific - you can update the state of a user or the other properties.
This is the description of the state parameter: The state of the user. This property can be used to restore a deleted user or transition between active and inactive. If specified, it is the only modifiable field.