Skip to content

Import Fingeprints

Legacy (Learn)

This page describes Learn fingerprints and the V1_LearnAPI group. Learn was replaced by Intuitive AI. For new work, use How Intuitive AI fits together.

This example looks in the specified directory for pairings of klfd and klff files which make up a Fingerprint. It then creates each Fingerprint in the target system changing the content type id to match the ID in that system. We do this because the Id (a GUID) will most likely not match the content type ID from the system the Fingerprint was originally exported from.

var clientConfig = new Configuration();
clientConfig.BasePath = "https://sampleUrl.knowledgelake.io/api";
clientConfig.AddApiKey("TempIdentityToken", "YOUR TOKEN HERE");
var learnClient = new KL.APIClient.Api.V1LearnAPIApi(clientConfig);

var importFromDirectory = @"C:\Fingerprints";
var newContentTypeId = Guid.Parse("30614bcd-248f-4f19-8a49-d9f90070c0bc");

foreach (var folder in Directory.GetDirectories(importFromDirectory))
{
    var definition = Directory.GetFiles(folder).Where(x => x.Contains(".klfd")).First();
    var files = Directory.GetFiles(folder).Where(x => x.Contains(".klff")).First();

    using (var definitionStream = File.OpenRead(definition))
    using (var filesStream = File.OpenRead(files))
    {
       var importResponse = await learnClient.V1LearnAPIControllerImportFingerprintAsync(definitionStream, filesStream, 
            JsonConvert.SerializeObject(new KL.APIClient.Model.ContentTypeMappingParameter {
                NewContentTypeId = newContentTypeId
            }));
    }
}