View Full Version : Working with OData

2017-01-27, 04:05
Lianja Cloud Server supports OData-compatible data access.

The Server handles ODBC connections as well as HTTP requests using OData URIs. In the following article I will show you how to use Lianja Cloud Server with OData URIs that will allow you to perform CRUD (Create, Read, Update and Delete) operations on your data.

Making OData requests from jQuery and/or the Lianja HTML5 Client in a Web App is extremely straightforward and simple.

Unlike other OData implementations, Lianja Cloud Server OData services does not require any server-side configuration of web services.


You can use Lianja cloud server odata calls to perform CRUD operations on virtual tables too so this functionality is not limited to native Lianja data; MSSQL, MySQL, PostgreSQL, Oracle and others are all supported.

Let me just emphasize again. Unlike other OData implementations, Lianja Cloud Server OData services does not require any server-side configuration of web services.

2017-01-27, 13:38
Hi Barry,

After successful playing with Southwind, I've tried with MS SQL and virtual table.
I made ODBC (32 / windows authentification) and got 19820 records in vt_customers of database cloudlibtest and I see them in grid.

Demo example_webvirtualtables works great too with this VT.

I cant get it in Chrome:


The requested page was not found
The requested URL /odata/cloudlibtest/vt_customers was not found on this server. works as expected
(the only thing I dont know how to open/use the result of $format=img)

I have tried with wwwroot settings in Lianja SQL Server Manager:
C:\lianja\sqlserver\wwwroot\ (from the blog screenshot)
and with
no avail.


2017-01-30, 09:26
Hi Josip,

Check the troubleshooter here: http://www.lianja.com/doc/index.php/Troubleshooting_example_webvirtualtables#Test_Web_ App

That is for the example_webvirtualtables App, but will also apply to accessing the vt_customers vt via direct OData URIs.



2017-01-30, 13:39
I can't get odata to work in Chrome with virtual table and MS SQL Server 2008 / ODBC DSN client 10.0

I passed all troubleshooting points but nothing improved (deploying stuff is not applicable because it is not an app, but Chrome).

The same happened if I use SQL Server authentication.

I was expecting that if I can get vt_customers to be shown in the grid (Data ws) then everything is OK with my DSN, MS SQL Server connection and permissions.
Also, if I can get to work in Chrome, then all is OK with Cloud Server.
That's why I am puzzled.

Something bothers me: what wwwroot need to be set?
In my Lianja Server Manager I initially found:

and in the blog it is

(have tried both. It doesn't matter for "odataing" southwind)

I wonder when doubleclicking on vt_customers in Data ws, from where (wwwroot) I get the records?
and from where in Chrome if I "odata" southwind or cloulibtest?

2017-01-30, 20:13
Using OData to query MSSQL is working fine for me.


The example shows how to use it with Lianja SQL Server.

wwwroot should be set to C:\lianja\cloudserver\tenants\public\wwwroot\

Remember also that you have the odata_create(), odata_read(), odata_update() and odata_delete() functions that can be used in both programs and rsp pages. These functions provide an OData abstraction above the target database SQL syntax. e.g. you can fetch MSSQL data using $limit (see below).


These examples were executed using the final release of Lianja 3.2 so try with that when it is available of download.

With regards to your question about $format=img, if you select an image field from a table then it will be output as an IMG tag with embedded data encoding so that you can insert this into the DOM to fetch and display an image.


By specifying memo fields you can also perform CRUD operations on JSON data.

Clearly there is a lot of power in this and it demonstrates how you can use Lianja Cloud Server to handle OData CRUD operations from other third party UI frameworks if that is a requirement. To use these OData functions on the client (no server side coding required) you should include the following files in your App:


This provides core javascript client side functionality for working with the LIanja Cloud Server. It is not required with Lianja Apps as they have the full framework included.

You can read and study the source code to see what functions are available in LianjaCloudDataServices.js

I keep mentioning over and over but I will do so again. Lianja OData as implemented in Lianja Cloud Server does not require any server side coding or web services and it can be used to perform CRUD operations on all native Lianja databases and all major SQL databases i.e. MSSQL, PostGreSQL, MySQL, Oracle and others.