Services > Data Engine Services > DataEngine Client Application > Consuming Data Engine Service |
This section demonstrates how to call the Web API service through a client application and fetch the data that is stored in Data Engine services. The client sends a GET request to the service, which returns a response stream. The response stream is then saved in the JSON format.
In the following example, we use “complex” as an example. It is the registered key for the DataEngine data source. The service URL takes in the Data Source name, location of dataset or collection, and the corresponding fields that are associated with the dataset.
Use the following javascript to call the Web API service, and fetch data from the service application.
<script>
$('#action-button').click(function() {
$.ajax({
type: 'GET',
url: 'http://localhost:7383/api/dataengine/complex/fields',
cache: false,
dataType: 'json',
processData: false,
success: function (data, tx, xhr) {
// the field list and total row count will be obtained from result.data.
// the data format is like the following
/*{
"data": [
{"binding":"Active","dataType":3},
{"binding":"Country","dataType":1},
{"binding":"Date","dataType":4},
{"binding":"Discount","dataType":2},
{"binding":"Downloads","dataType":2},
{"binding":"ID","dataType":2},
{"binding":"Product","dataType":1},
{"binding":"Sales","dataType":2}
]
}*/
}
})
});
</script>