box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
222 stars 59 forks source link

I can not request the updated_at date for files #540

Closed cschaba closed 1 month ago

cschaba commented 1 month ago

Description of the Issue

I want to create a list of files for a folder and what to output the updated_at field, but it's missing in the output. Other fields, like created_at are shown correctly.

Steps to Reproduce

box folders:items --as-user=123456789 --sort=date --json --fields=type,id,name,created_at,updated_at 123456789
...
    {
        "type": "file",
        "id": "123456789",
        "name": "Document.pdf",
        "created_at": "2020-09-01T02:59:09-07:00"
    },
...

I wonder also where to find a complete list of valid fields, I took the example output of https://developer.box.com/reference/resources/file-request/ as reference, is that the right source?

I also wonder which date field for the --sort=date option is used. Is it created_at or updated_at?

Expected Behavior

I would expect the updated_at field in the output.

Versions Used

Box CLI: @box/cli/3.14.1 darwin-x64 node-v14.19.3 Operating System: MacOS 15.0

arjankowski commented 1 month ago

Hi @cschaba,

The command you are performing corresponds to this API call

If you want to obtain a specific field that is not returned by default, you need to specify it in the fields parameter. As for the possible fields that can be passed in the fields parameter, they can be any of the available fields of the returned resources.

Since List items in folder returns three resources file, folder, weblink, you can find the possible fields here: file: https://developer.box.com/reference/resources/file--full/ folder: https://developer.box.com/reference/resources/folder--full/ weblink: https://developer.box.com/reference/resources/web-link/

In your case, since you are interested in the update date, you need to pass the corresponding field which is modified_at described here.

So the final query should look like this:

box folders:items --as-user=123456789 --sort=date --json --fields=type,id,name,created_at,modified_at 123456789

Regards, Artur

cschaba commented 1 month ago

@arjankowski Thank you very much for your reply. Using modified_at instead of updated_at works for me. Thanks for pointing to the "full" documentation.

Maybe there is some potential to update the CLI Docs with this links?

I wonder which date field is used when using the --sort=date .

Is it created_at or modified_at?

Thanks 👍

arjankowski commented 1 month ago

@cschaba I'm glad that this solved your problem.

When it comes to --sort=dateIt looks like it uses the created_at date.