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

Python parsing file object

Answered
New post

Comments

3 comments

  • mwiller

     I think the issue might lie in your iteration over the `path_collection` dictionary — you probably only need one for loop, like this:

     

    for pc_entry in entry['path_collection']['entries']:
        box_folderpath = box_folderpath + pc_entry['name']
    0
    Comment actions Permalink
  • chanmar

    Omg that was it! Thank you so much!

     

    Can I ask another question? I notice that when I search_folders it doesn't returns "tags" in the response even though my file has tags on it. Was this dropped from the file object, or am I just reading it correctly?

    0
    Comment actions Permalink
  • mwiller

     According to the API documentation at https://developer.box.com/v2.0/reference#file-object, the `tags` field is not included in the file object response by default — you need to specifically request it from the API using the `fields` query parameter.  Unfortunately, the Python SDK does not currently make it easy to pass that in — we're working on a big update for the SDK which should include full API parity across all endpoints, but it's not ready yet.  In the meantime, you should be able to make the call manually by doing something like this:

     

    params = {
        'fields': 'type,id,tags', # add any other fields you need here
        'query': '.pdf',
        'file_extensions': 'pdf',
    }
    resp = client.make_request('GET', 'https://api.box.com/2.0/search', params=params).json()
    
    0
    Comment actions Permalink

Please sign in to leave a comment.