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

Can't query metadata #494

Closed c-rei closed 11 months ago

c-rei commented 1 year ago

I want to get some metadata with CLI like below, and I got some error. I am a owner of the folder which queried.

box metadata-query enterprise_12345.template4 12345678900 --as-user=22222222

Unexpected API Response [403 Forbidden | 0a85ec5347cca63c9433d9a39c20127b1.0a85ec5347cca63c9433d9a39c20127b1] metadata_query_restricted - Metadata Query API found either too many items outside the ancestor folder or too many inaccessible items matching the query.

Versions Used

Box CLI: @box/cli/3.11.0 win32-x64 node-v14.19.3 Operating System: Windows 10

So, I want to known what's wrong with my CLI? Thanks any response.

mwwoda commented 1 year ago

Hi @c-rei The error appears to be coming from the API itself. There are two possible causes for this error, as the error message indicates. Either the query returns too many results, or you don't have permissions to all items in the result set. For more information, see https://developer.box.com/guides/metadata/queries/limitations/#recommended-result-set-size. I recommend narrowing down the query and making sure that the user has the correct permissions set.

c-rei commented 1 year ago

Hi mwwoda Thanks your response. But I am a owner of the ancestor folder, --as-user=my user id. I don't known how to narrowing down the query, I used the ancestor folder id, and only five files under that folder. So I no have a permission problem, and if the ancestor folder id can narrow the result, that does not exceed 2,000 items.

Also, if I query a template which set a few items, it works at folder id = 0, and some other folder id, so I think the result exceeds 2,000 items before the ancestor folder id limit.

mwwoda commented 1 year ago

According to the documentation, you should have Previewer permissions on all elements of the result set. The CLI in this case only returns an API response (you could probably get the same error by making same call with cURL). The problem most likely lies either in the API or in the specific configuration of your environment. You can try contacting support on our forum https://forum.box.com/latest if you think the problem is related to the API.

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.

stale[bot] commented 11 months ago

This issue has been automatically closed due to maximum period of being stale. Thank you for your contribution to Box CLI and feel free to open another PR/issue at any time.