Using API
Template
Different ways of using API
Template
Different ways of using API
eKansio API offers full resources list of getting/setting application schema and data, because the API is used also internally. See available resources
cms -object offers resource to make ajax calls to eKansio API.
Set response to a variable (synchronous call!)
var response = cms.api.get('record', {table:'customer', id:customer_id});
Handle data with callback function:
cms.api.get('record', {
table:'customer',
id:customer_id
}, function(response){
// Do stuff with response.data
});
More examples of fetching data.
eKansio allows cross-domain ajax calls to enable making ajax -calls from remote site.
eKansio provides Javascript object for making calls to api:
var Api = eApi.create({
host: 'http://www.ekansio.fi',
username: 'demouser',
password: '1234',
});
Api.get('record',{
table:'customer',
id:customer_id
},function(){
// Do stuff with eKansio data
});
This way you expose you password in public code!!
Actions can be called using api/action/:id/print -resource. You can run the action and get the content of any ActionType, but to make API resources it is adviced to use text type
Add customer info inside DOM element:
cms.api.get('action/customer_orders_table/print',{
id: customer_id
}, data => {
$('.js-orders').append(data);
})