cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extracting variable from SearchMatchV2 Result

Extracting variable from SearchMatchV2 Result

yiannimercer
New member | Level 2

Hello,

 

I am using the search function in the Dropbox API for Python, and I need to be able to extract the path_lower variable from the SearchV2Result.  Hopefully someone can help me with this.

 

My Code:

 

 

dbx.files_search_v2('Test')

 

 

Output:

 

 

SearchV2Result(cursor=NOT_SET, has_more=False, matches=[SearchMatchV2(highlight_spans=NOT_SET, match_type=SearchMatchTypeV2('filename', None), metadata=MetadataV2('metadata', FolderMetadata(id='id:CMgvcnxDzGAAAAAAAAAAVA', name='Test', parent_shared_folder_id=NOT_SET, path_display='/wyss-predictive-bioanalytics/Yianni/Test', path_lower='/wyss-predictive-bioanalytics/yianni/test', property_groups=NOT_SET, shared_folder_id=NOT_SET, sharing_info=FolderSharingInfo(no_access=False, parent_shared_folder_id='9501352096', read_only=False, shared_folder_id=NOT_SET, traverse_only=False))))])

 

 

 

Again, I would like to extract the path_lower variable, so in this case, it would be '/wyss-predictive-bioanalytics/yianni/test'.  Thanks! 

1 Reply 1

Greg-DB
Dropbox Staff

The files_search_v2 method returns a SearchV2Result, which has a list of SearchMatchV2 in its 'matches' variable. Each SearchMatchV2 has a MetadataV2 object in its 'metadata' variable, so you can access the Metadata object and its variables, such as 'path_lower', like this:

 

search_result = dbx.files_search_v2('Test')

for match in search_result.matches:
    if match.metadata.is_metadata():
        print(match.metadata.get_metadata().path_lower)
    else:
        # handling for other types here
        pass

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?