BOXCLI --id-only not working
Getting error when trying to use --id-only option.
C:\BoxCLI>box folders list-items 12xxxxx7 --as-user 2xxxxx6 -id-only Specify --help for a list of available options and commands. Unrecognized option '-id-only'
-
Two things to note here:
-id-only won't work because the option has two dashes "--id-only".
Also, currently --id-only isn't supported on that command. If you need that feature, you can file an issue on the Box CLI Github for a feature request (https://github.com/box/boxcli).
As you can see from the screenshot, --id-only is not a listed option for this command:
In the meantime, you can parse the JSON from the API with Bash or PowerShell:
Bash:
There isn't a built in bash tool that lets you easily parse a JSON string. There are some tools you can download, but I opted just to use Python.
box folders list-items 0 --json | python -c '
import sys, json
parsed = json.load(sys.stdin)["entries"]
for entry in parsed:
print entry["id"]
' >> ids.txt
The spacing and line breaks are important here since it's Python. This writes out a list of the IDs to a .txt file. You can pipe the output to whatever you'd like. I just used creating a file as an example.
PowerShell
PowerShell has a built in JSON parser:
$json = box folders list-items 0 --json | ConvertFrom-Json
echo $json.entries.id
Please sign in to leave a comment.
Comments
1 comment