Searching with API with multiple Ancestor_Folder_IDs

New post



  • jcleblanc

    Hi ,


    I took a look at the query method for the Python SDK and it looks like they're using "ancestor_folders" instead of "ancestor_folder_ids" as a param, then joining whatever is passed there into the API call using ancestor_folder_ids.


    Can you try swapping ancestor_folder_ids for ancestor_folders and see if that helps?


    - Jon

    Comment actions Permalink
  • akvaternik

    I tried changing the search parameter from "ancestor_folder_ids" to "ancestor_folders" and had no luck. The BoxSDK generated an error on line 276 of the when trying to obtain the object_id of the folder that was passed (see screenshot). I tried passing one folder and then again with 2 folders; same result.

    See the source code below showing the call to the search API that is generating the error. I get the same error if I change the search API call with 2 folders "ancestor_folders=[account_folder_id,oppty_folder_id]" to call only 1 folder - "ancestor_folders=[account_folder_id]".



    oppty_folder_id     = "21075437786"
    account_folder_id   = "7***phone number removed for privacy***"
    def process_files(search_folder):
        if search_folder == "account":
            this_folder = account_folder_id
            this_folder = oppty_folder_id
        box_items ='coi',
                                          fields=['id', 'type', 'modified_at', 'name', 'parent', 'path_collection']



    See the screenshots below for the error message generated, and the debug listing showing the variable values when 1 or 2 folders are passed to the API.


    You really should update the Box API search documentation to state that the correct parameter is "ancestor_folders" and not "account_folder_ids". In debugging the API calls, when the search parameter is "ancestor_folder_ids=[xxxxx]", the SDK determines that the parameter is empty because nothing is passed with "ancestor_folders".

    Comment actions Permalink

Please sign in to leave a comment.