Welcome to the new Box Support website. Check out all the details here on what’s changed.

Search API feature for fetching all files metadata information

New post

Comments

5 comments

  • mwiller

     You can use the `fields` query parameter to specify that you want metadata returned with your search results, like this:

     

    curl -H"Authorization: Bearer ACCESS_TOKEN" https://api.box.com/2.0/search?query=Test&fields=name,metadata.enterprise.mymetadata
    0
    Comment actions Permalink
  • vijeeshciber

    Thanks for your information. I have tried with same format for field. But i am getting metadata with null values. Is there any other information need to add for this 

    0
    Comment actions Permalink
  • mwiller

     Did you replace the template name in the field parameter to match the actual metadata template key you want to retrieve?  The format should be `metadata..` where scope is either "global" or "enterprise", and templateKey is the key of the metadata template you want.

    0
    Comment actions Permalink
  • BB_Jake

     Thank you for your post, this was the exact information I needed as I was facing the same issue with needing the files metadata to be returned when i performed a search.

    My concern is I only found this solution in a forum post. I first came across the setFields(List fields) method in the Java SDK and it seemed like it would be helpful so i started searching the box search api documentation (https://developer.box.com/reference#searching-for-content) and it described the 'fields' parameter but i could not find any list of available fields that were allowed to be used. Are all available fields documented somewhere? 

     

    UPDATE : looking a little harder i found the file object definition (https://developer.box.com/reference#file-object) that specifies some parameter names, would be helpful to show a full example for the metadata one like you posted here though 🙂

    metadata..
    
    object
    
    Specific metadata on the file, identified by scope and templateKey. The limit of metadata instances to be requested this way is 3.

     

     /**
         * Set the existing fields that are used for the search criteria.
         * @param fields specify what fields to be returned.
         */
        public void setFields(List fields) {
            this.fields = fields;
        }

     

    Fields
     
    Each object has "standard" and "mini" formats, which include a certain set of fields:
    
    The standard format is returned when you request a specific object (e.g. GET /files/{id}).
    The mini format is returned when the object is part of a set of items (e.g. GET /files/{id}/comments).
    Less-frequently used fields are not included in either the standard or mini format. These are listed in italics in the object definitions.
    In addition to the standard and mini formats, you can have the API return a specific set of fields using the fields query parameter. Specify a comma-separated list of the field names (with no spaces after the commas). Only the fields you request are returned, as well as the type and id fields (which are always returned). For example, if you call GET /files/{id}?fields=modified_at,path_collection,name, it will return the type, id, modified_at, path_collection, and name fields.



     

    0
    Comment actions Permalink
  • Kourtney

     I will ensure this feedback is relayed to our developer documentation team! Thank you for all the input! 

    0
    Comment actions Permalink

Please sign in to leave a comment.