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

Search api is not returning custom metadata in response

Answered
New post

Comments

4 comments

  • cbetta

    Hi  have you tried adding the `fields` query param? This will allow you to request extra fields in the response for each file, like the `metadata` object.

    0
    Comment actions Permalink
  • nsydaiah

     I have tried with fields=modified_at,path_collection,name,metadata, but still not returning the metadata. Here is the URL:

    https://api.box.com/2.0/search?mdfilters=%5B%7B%22templateKey%22%3A%22customer%22%2C%22scope%22%3A%22enterprise_7133495%22%2C%22filters%22%3A%7B%22eid%22%3A%22abcd1234%22%7D%7D%5D&fields=modified_at,path_collection,name,metadata

     

    Here is response from service:

    {"total_count":2,
    "entries":
    [{"type":"file","id":"508880648946","etag":"0","modified_at":"2019-08-16T11:01:05-07:00",
    "path_collection":{"total_count":3,"entries":[{"type":"folder","id":"0","sequence_id":null,"etag":null,"name":"All Files"},
    {"type":"folder","id":"8***phone number removed for privacy***","sequence_id":"0","etag":"0","name":"Secure Files"},
    {"type":"folder","id":"84660484843","sequence_id":"0","etag":"0","name":"111"}]},
    "name":"new 1.json"},
    {"type":"folder","id":"8***phone number removed for privacy***","etag":"0","modified_at":"2019-08-15T12:51:26-07:00",
    "path_collection":{"total_count":2,"entries":[{"type":"folder","id":"0","sequence_id":null,"etag":null,"name":"All Files"},
    {"type":"folder","id":"8***phone number removed for privacy***","sequence_id":"0","etag":"0","name":"Secure Files"}]},"name":"444"}],
    "limit":30,"offset":0}

    0
    Comment actions Permalink
  • cbetta

     I had to do some digging.

     

    To return a specific metadata template, use `fields=metadata.scope.templateKey`. You can combine this to fetch multiple results, e.g. `fields=metadata.global.properties,metadata.emteprise_12345.securityClassification-123123`.

     

    To get all metadata on a file, use the file metadata endpoint, `/2.0/files/:file_id/metadata`.

     

     

     

    0
    Comment actions Permalink
  • nsydaiah

    Query param works for me

    0
    Comment actions Permalink

Please sign in to leave a comment.