Configure the Upload

Configure the external data upload by inserting a row into the InsightsExternalData object and setting configuration values.

After establishing a connection with Salesforce, insert a row into the InsightsExternalData object to configure and control the upload.

The InsightsExternalData object provides a “header” that contains information about the upload, such as the name of the dataset, the format of the data, and the operation to perform on the data. You can also provide the metadata file.

If you are uploading a CSV file without a header row, you must set the numberOfLinesToIgnore value to 0 in the metadata file. If you don’t set this value, the first row of every data part upload may be lost. For more information on the metadata file, see External Data Metadata Overview.

The following example inserts a row into the InsightsExternalData object and sets configuration values.

1SObject sobj = new SObject();
2sobj.setType("InsightsExternalData");
3sobj.setField("Format","Csv");
4sobj.setField("EdgemartAlias", DatasetName);
5sobj.setField("MetadataJson",metadataJson);
6sobj.setField("Operation","Overwrite");
7sobj.setField("Action","None");
8
9SaveResult[] results = partnerConnection.create(new SObject[] { sobj });
10
11for(SaveResult sv:results)
12    if(sv.isSuccess())
13        parentID = sv.getId();

The WSC converts the metadata .json file to a Base64-encoded string, but if you’re using REST API, you need to make this conversion yourself.

Note

For detailed information about the InsightsExternalData object, see The InsightsExternalData Object.