Box Java SDK - Search Result display fields
Hi,
I am using Box Java SDK to search files from box. I need to search and display "Tags" of the files with the search result.
I tried to add the "tags" field in BoxSearchParameters as explained in the documentation, but this is returning null in the resultset, however other fields are populated with data. (File is having tags)
Code is something like the following:
BoxAPIConnection api = BoxAuthenticationUtil.initiateBoxAPIConnection();
BoxSearch boxSearch = null;
if(Validator.isNotNull(api)){
boxSearch = new BoxSearch(api);
}
BoxSearchParameters bsp = new BoxSearchParameters();
bsp.setQuery("searchquery");
List fields = new ArrayList();
fields.add("name");
fields.add("shared_link");
fields.add("tags");
bsp.setFields(fields);
PartialCollection searchResults = null;
searchResults = boxSearch.searchRange(0, 10, bsp);
try {
for (BoxItem.Info currentItemBox : searchResults) {
log.info("Name: " + currentItemBox.getName()); // printing name
log.info("Name: " + currentItemBox.getSharedLink().getURL()()); // printing URL
log.info("Name: " + currentItemBox.getTags()); // printing null
}
} catch (Exception e) {
_log.error("Error while getting Box Results" + e.getLocalizedMessage());
if (_log.isDebugEnabled()) {
_log.debug(e, e);
}
}
-
Hi ,
This may be a silly question, but are you sure that the file information that you're pulling down has tags associated with it? For instance, if you view that file in the Box web app are you able to see tags for those files? Null would be returned for the value if no tags are present.
Thanks,
Jon
Please sign in to leave a comment.
Comments
2 comments