Error piping data into callforwarding CLI

I am trying to set Call Forwarding for a user using the CLI.

I'm not sure what I'm doing wrong, but I receive a 400 error"The request could not be understood by the server due to malformed syntax."" when trying to pipe in the data. If I use the "-f" option and use the same JSON, it works as I'd expect.

Command that fails:
echo '{"enabled": true, "calls": [ { "targets": [ { "type": "PHONENUMBER", "value": "+1##########" } ] } ], "voicemail": "NONE"}' | gc users callforwarding patch User ID -p Environment

Command that works:
gc users callforwarding patch User ID -p Environment -f "Payloads\Call Forwarding Test Data.json"

Hi Chad

I tried piping json to a gc command in the same way you did, and it worked okay for me.

I assume if you copy and paste the json from the pipe command into the json file, and try to run the latter command, it still works okay? My first guess is that there must be some different between the json string and what is in the file.

Thanks for checking Charlie. I figured out the problem. I was putting the string being piped in single quotes and in Windows, I don't need the single quotes. So this is what I found works:
echo {"enabled": true, "calls": [ { "targets": [ { "type": "PHONENUMBER", "value": "+1##########" } ] } ], "voicemail": "NONE"} | gc users callforwarding patch User ID -p Environment

1 Like

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