Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Box CLI - use box folders:get command

Answered
New post

Comments

4 comments

  • mwiller

     I'm not sure I understand exactly what problem you're seeing; would you mind providing a bit more information so we can try and troubleshoot?

     

    First, exactly what command are you running with the v2 CLI to write the output to file?  Next, it would be really helpful if you could provide redacted/sample versions of the output you're seeing and the output you expect to see so I can make sure I know precisely what you're looking for.  Thanks!

    0
    Comment actions Permalink
  • BoxUser100

    Sure no problem. I think the easiest way to see what I'm doing is to follow my steps. I start by running this command 

     

    box folders:get 0 --as-user  

    That returns a JSON response that lists every folder at the root level for that user.

     

    So I decided that I'd like to export that response into something more palatable, like a CSV file. So I run this command next. 

     

    box folders:get 0 --as-user  --save

    The export CSV file that comes back is two rows that don't seem to have anything to do with the response from the first command. I was assuming that adding the "--save" command would provide the same report but exported as a CSV.

     

    Here is the CSV report with the two rows of info.

     

    type id name description size path_collection.total_count path_collection.entries created_by.type created_by.id created_by.name created_by.login modified_by.type modified_by.id modified_by.name modified_by.login owned_by.type owned_by.id owned_by.name owned_by.login item_status item_collection.total_count item_collection.entries item_collection.offset item_collection.limit item_collection.order
    folder 0 All Files   382530 0 Array user       user ID redacted Name redacted Email redacted user ID redacted Name redacted Email redacted active 83 Array 0 100 Array

     

    Does that make more sense?

    0
    Comment actions Permalink
  • mwiller

     Ah, I think I see what the issue is.  You're using the box folders:get command, which is made for retrieving information about a single folder.  The folder object includes an item_collection field, which displays a preview of the items in a folder — just the first 100 of them.  This is probably what you're seeing in the JSON output.  However, that sort of nested array of objects would be very difficult to represent directly in a CSV format, so we simply replace it with Array, which you can see under the item_collection.entries key in the CSV output you posted.  If you want to get the full list of items in a folder, not just a preview of the first 100, you'll want to use the box folders:items command instead; that should allow you to output the CSV the way you want it.  Could you give that a try and let me know if it works for you?

    0
    Comment actions Permalink
  • BoxUser100

    Thanks so much. Your solution provided what I needed. 

    0
    Comment actions Permalink

Please sign in to leave a comment.