Skip to main content
Question

Different results Java vs .NET SDK

  • May 23, 2025
  • 2 replies
  • 23 views

Forum|alt.badge.img

I have 2 applications that searches for a set of documents in Box.

A .NET module, here I use the SearchManager:

  public async Task<BoxCollection<BoxItem>> searchFilesByMetaData(BoxClient boxClient, Dictionary<string, object> searchCriteria, string templateName)
        {

            var mdFilter = new BoxMetadataFilterRequest()
            {
                TemplateKey = templateName, 
                Scope = "enterprise",
                Filters = searchCriteria
            };

            // Initiate search
            return await boxClient.SearchManager.QueryAsync("", mdFilters: new List<BoxMetadataFilterRequest>() { mdFilter }, type: "file");
        }

A Java application where I use searchRange:

// zoek instructie
        BoxSearch boxSearch = new BoxSearch(api);
        BoxSearchParameters boxSearchParameters = new BoxSearchParameters();
        PartialCollection<BoxItem.Info> deelResultaat = new PartialCollection<BoxItem.Info>(0, limitValue, limitValue);
        
        // metadata filter opbouwen
        BoxMetadataFilter metaDataFilter = new BoxMetadataFilter();
        boxSearchParameters.clearParameters();
        boxSearchParameters.setType("file");
            
        // Voeg de criteria toe aan het filter
        metaDataFilter.setScope("enterprise");
        metaDataFilter.setTemplateKey(template);
        
        if (metadata != null) {
            metadata.forEach((key, value) -> {
                metaDataFilter.addFilter(key, value);
            });
        }
                
        boxSearchParameters.setMetadataFilter(metaDataFilter);
        
        // Fileinfo velden inclusief metadata opvragen
        List<String> fields = new ArrayList<String>();
        fields.add("created_at");
        fields.add("created_by");
        fields.add("description");
        fields.add("expires_at");
        fields.add("metadata.enterprise." + template);
        fields.add("modified_at");
        fields.add("modified_by");
        fields.add("name");
        fields.add("owned_by");
        fields.add("size");

        boxSearchParameters.setFields(fields);
        
        List<BoxItem.Info> zoekResultaat = new ArrayList<BoxItem.Info>();
        // zoek resultaat
        try {
            do {
                deelResultaat = boxSearch.searchRange(offsetValue, limitValue, boxSearchParameters);
                logger.trace("deelresultaat gevonden: " + deelResultaat.size());
                zoekResultaat.addAll(deelResultaat);
                offsetValue += limitValue;
            } while (deelResultaat.size() >= limitValue);
            
        } catch (BoxAPIException be) {
            
            String melding = "[FOUT_JAVA] Box zoekopdracht is niet juist in BoxLibrary metadataZoekOpdracht functie ! zoek parameters onjuist: " + be.getMessage() + ", Scope: " + metaDataFilter.getScope() + ", Template: " + metaDataFilter.getTemplateKey() +", Filter: " + metaDataFilter.getFiltersList().toString() + " \n";
            String httpResponseStatusCode = "" + be.getResponseCode();
            this.interneFoutLijst.add(new BoxError("CNC-BOX-SEA", melding, httpResponseStatusCode));
        }
        
        logger.trace("end metadata search");
        return zoekResultaat;

Via the Java SDK the files for the document set are always found, no problems here.

Via the ,NET SDK some files of the document set are not found. Most sets are complete, some are not.

Do I use the wrong method, missing a parameter?

 

2 replies

Forum|alt.badge.img

Problem solved!

The .NET app had an older certificate for authentication.


Forum|alt.badge.img

Thank you for letting us know what the problem was! 

Alex, Box Developer Advocate