Powershell and CLI with updating Auto Answer

Hey All I am having an issue. I am trying to update autoanswer of one user using the CLI. My code is:

echo '{acdAutoAnswer": "true"}' | gc.exe users update $userid

and my output is as follow:

gc.exe : {
At line:2 char:36

  • ... "true"}' | gc.exe users update f6ac8a19-dd74-495b-aa8f-68a04ca28ada

  •              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: ({:String) [], RemoteException
    • FullyQualifiedErrorId : NativeCommandError

    "message": "The request could not be understood by the server due to malformed syntax.",
    "code": "bad.request",
    "status": 400,
    "contextId": "af0c9999-1156-4693-a45f-f318d9c7530e",
    "details": [],
    "errors": []
    }

Any ideas?

Hello,

The "gc.exe users update $userid" coresponds to a PATCH /api/v2/users/{userId}
version is a mandatory input parameter.

I mean the current version number you see when requesting user info: "gc.exe users get $userid"
The command would then be (assuming you have stored current version number in something like $usercurrentversion):
echo '{"acdAutoAnswer": true, "version": '$usercurrentversion'}' | gc.exe users update $userid

But you can use another endpoint if you are trying to update multiple users at once (or even just one). The maximum is 50 per requests.
This is using "gc.exe users bulk update" - which corresponds to: PATCH /api/v2/users/bulk
echo '[{"id": "'$userid'", "acdAutoAnswer": true}]' | gc.exe users bulk update

Regards,

I actually figured this out after I posted this. my previous script spits out a csv with who needs auto answers set up and here is my code that is currently working:
$autoanswer = import-csv csv_file_here
$userid = (gc.exe users list -a | ConvertFrom-Json) | Where-Object email -eq $autoanswer.email | Select-Object -ExpandProperty id
$version = (gc.exe users list -a | ConvertFrom-Json) | Where-Object email -eq $autoanswer.email | Select-Object -ExpandProperty version
$Raw = @{
acdAutoAnswer = "true"
version = "$version"
}
$json = $raw | ConvertTo-Json
echo $json | gc.exe users update $userid

I will wrap this in a foreach to iterate through each user who needs autoanswer.

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