Train dataset using Apex

To train the dataset, the sample CURL command is as follows:

curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "name=Customer Service Item Model" -F "datasetId=1002055" https://api.metamind.io/v1/vision/train

As noted, the request involves a content type of multipart. We will use the utility we built while creating a dataset to form the request body. The following is the utility to build the blob request body:

    private static Blob buildBlobBody(String name,String datasetId) {      String body = '';      body += EinsteinVisionUtility.WriteBoundary();      body += EinsteinVisionUtility.WriteBodyParameter('name', name); body += EinsteinVisionUtility.WriteBoundary(); ...

Get Learning Salesforce Einstein now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.