2

Trailhead consists of creating a Dataset with the given URL(https://developer.salesforce.com/files/Cats.zip)

But how can we create our own Dataset, if we have all the images in Local system.

0

The trailhead module used a service class called EinsteinVision_PredictionService to get the data from the zip and then load it into the Einstein REST API..

public Einstein_Dataset createDatasetFromUrlAsync(String url) {
    System.debug('Starting createDatasetFromUrlAsync call from URL ' + url + ' for type ' + typeString + '.');
    Einstein_HttpBodyPartDatasetUrl parts = new Einstein_HttpBodyPartDatasetUrl(url, typeString);
    Einstein_HttpClient client = new Einstein_HttpClient(this, '/datasets/upload', parts.build());
    client.isPost(true);
    System.debug('Target URL is ' + client.getUrl());
    client.execute();
    while(isExecuting()) {
        System.debug('Status is: ' + isExecuting());
    }
    System.debug('Call createDatasetFromUrlAsync has been executed.');
    if (!client.isError()) {
        Einstein_Dataset dataset = (Einstein_Dataset)client.getParser().readValueAs(Einstein_Dataset.class);
        System.debug('New dataset with id ' + dataset.id + ' has been created.');
        return dataset;
    }
    handleError(client.getStatusCode(), client.getResponseError());
    return null;
}

All the source code is here:

You can follow the Apex code example to understand how they have done it.

The Einstein REST API documentation will also help:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.