DataMapper REST API to query data against DataMapper

Hi Guys,

I was wondering if anyone could help me, I’m looking to query the DataMapping REST API service to run data through a DataMapping configuration without executing an All-In-One which would subsequently error.

Regardless of where I seem to load datamappers/data, etc, I get the repsonse;

Result: There was an error processing the JSON string caused by: The JSON configuration string is empty. (SRV000090) (SRV000081)

I am fairly new to calling APIs, would anyone be kind enough to point me in the right direction?

// REST API CALL TO MAPPER SERVICE //
var dataMapperId = “cpsdatamapper.OL-datamapper”;
var dataFileId, operationId, fileContent;
var xhr = new ActiveXObject(“Microsoft.XMLHTTP”)

    var bs = new ActiveXObject("Adodb.Stream");
    bs.Type = 1;
    bs.Open();
    bs.LoadFromFile(Watch.ExpandString("%F"));
    fileContent = bs.Read;
    bs.Close();
    //Upload data config
    url = "http://localhost:9340/rest/serverengine/filestore/DataFile?persistent=false";
    xhr.open("POST", url, false);
    xhr.setrequestHeader("Content-Type","application/octet-stream");
    xhr.send(fileContent);
    dataFileId = xhr.ResponseText;

    //Validate data against mapper
    url = "http://localhost:9340/rest/serverengine/workflow/datamining/" + dataMapperId + "/" + dataFileId + "?validate=true";
    xhr.open("POST", url, false);
    xhr.setrequestHeader("Content-Type","application/json");
    xhr.send();
    operationId = xhr.getResponseHeader("operationId");

    //Get result
    url = "http://localhost:9340/rest/serverengine/workflow/datamining/getResult/" + operationId;
    xhr.open("POST", url, false);
    xhr.setrequestHeader("Content-Type","application/json");
    xhr.send();
    Watch.Log("URL: " + url, 1);
    Watch.Log("Result: " + xhr.responseText, 1);
    //Watch.Log("Result: " + JSON.parse(xhr.responseText).result, 1);
url = "http://localhost:9340/rest/serverengine/workflow/datamining/" + dataMapperId + "/" + dataFileId + "?validate=true";
        xhr.open("POST", url, false);
        xhr.setrequestHeader("Content-Type","application/json");

From what I can see the above request does not expect application/json content type. Try without specifying the content type at all.

Alternatively, if you want to use JSON you can pass the data file ID as json structure, but skip dataFileId in the request URL