[CLI/PowerShell] Unable to set manager with gc users update

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?)

Hi Matej,

Can you send an exaple of one of the command you are trying?

Regards,
Declan

Sure thing, here's an example:

Update command:
($newUser | ConvertTo-Json -Depth 15) | gc.exe users update $newUserId

Example value of $newUser:

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

Hi Matej,

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.

Regard,
Declan

Hello,

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.

Regards,

I've removed both the ID and State from the request body. I can confirm the update works now.

Thanks for the clarification, much appreciated!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.