Box CLI search command
AnsweredHi all, I'm probably overlooking something minor with the CLI search command, but I can't get it to work. I think it is probably related to my search term, which I have tried to encapsulate in single quotes, double quotes, curly braces etc.
Can anyone point out what I'm doing wrong with this command? Thanks in advance, Matt.
PS/>box search move-test --as-user 1234 --type file --file-extensions docx
-
Hey Matt!
Thanks so much for using our Platform and Development Forum!
One important thing to keep in mind is that the account the CLI is associated with is the JWT service account. Therefore, when you search without using the as-user header, you're only searching within the service account's folder tree. Is "move-test" in a file/folder located in your account or in the service account?
Also, what response are you seeing when you make this call?
Best,
Kourtney
-
Hi Kourtney,
Thanks for getting back to me. I'm using my own user ID as I'm the Box Administrator. The file was created by myself, located in a folder created by myself.
The error response I'm getting is as follows.
{ "type": "error", "status": 400, "code": "bad_request", "context_info": { "errors": [ { "reason": "invalid_parameter", "name": "created", "message": "Invalid value '2018-03-03T09:06:17 00:00'." } ] }, "help_url": "http://developers.box.com/docs/#errors", "message": "Bad Request", "request_id": "i3egr3fuweyl4uwb" }
It doesn't tell me which parameter is invalid though. I've tried several permutations of the the command string with no success.
I can use other 'files', 'folders' and 'users' commands to find the information I need to complete my task, which was to build a script to bulk move several thousand files from one folder to another. I thought it would be quicker to use the 'search' API though as fewer commands would have to be typed to build my script.
Thanks,
Matt.
-
Matt,
The error I'm seeing on the backend is: "Invalid+date+in+the+date+range+for+created"
Please ensure the date you're passing is formatted correctly. If you go to https://developer.box.com/v2.0/reference#api-docs-directory and scroll down to the "Date Format" section there are some examples of proper formatting.
Best,
Kourtney
-
Hi ,
I've run the request again, please find the response body below.
{ "type": "error", "status": 400, "code": "bad_request", "context_info": { "errors": [ { "reason": "invalid_parameter", "name": "created", "message": "Invalid value '2018-04-16T08:57:42 01:00'." } ] }, "help_url": "http://developers.box.com/docs/#errors", "message": "Bad Request", "request_id": "gs5a8tfwa4cwx4b0" }
The time zone I'm in is London (UTC + 1:00) and I ran this request at about 08:57 on the 16/10/2018.
Thanks,
Matt.
Please sign in to leave a comment.
Comments
10 comments