Java SDK metadata search files available not found

新規投稿

コメント

2件のコメント

  • 正式なコメント
    Alex Novotny

    Hello, 

    Hmm. That is very odd. Can you send me the code you are running for both .net and java? I'm interested in comparing them. 

    Thanks, 

    Alex, Box Developer Advocate

    コメントアクション パーマリンク
  • smartduck

    Hello Alex,

    The code is simple:

    Java version

    BoxSearch boxSearch = new BoxSearch(this.api);
    BoxSearchParameters boxSearchParameters = new BoxSearchParameters();
    PartialCollection<BoxItem.Info> totaalResultaat = new PartialCollection<BoxItem.Info>(0, 200, 200);

    // 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);

    metaDataObject.keySet().forEach(keyStr ->
    {

    Object keyValue = metaDataObject.get(keyStr);
    String filterItem = BoxMetadataHashtable.getMetadataVeldSleutel(DMGStringLib.naarCamelCase(keyStr.toString())).getKey();

    metaDataFilter.addFilter(filterItem, keyValue.toString());
    });
    boxSearchParameters.setMetadataFilter(metaDataFilter);

    zoekResultaat = boxSearch.searchRange(offsetValue, limitValue, boxSearchParameters);


    .NET version


    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");
    }

    Regards,

    Marcel

    0
    コメントアクション パーマリンク

投稿コメントは受け付けていません。