Hello
The sample server is attached: ODataServer (Delphi).zip (63.3 KB)
It uses the standard sample SQLite database shipped with Data Abstract.
Accessing a table:
GET http://localhost:8099/odata/Customers?$format=json
Accessing a table with some condition applied:
GET http://localhost:8099/odata/Customers?$format=json&$filter=Name eq 'Ana Trujillo'
Accessing single record in the table:
GET http://localhost:8099/odata/Customers/{3217032b-47db-400a-9a6e-012cbdf1e1e5}?$format=json
Inserting a row
POST http://localhost:8099/odata/Customers?$format=json
with a body like
{"d":{
"__metadata": {
"uri": "http://localhost:8099/odata/Customers",
"type": "ODataService.Customers"
},
"Id":"{11111111-1111-1111-1111-111111111111}","Name":"Ana Trujillo","Phone":"(5) 555-4729","Address":"c6be7eec-6a39-48c1-b2c5-5b2c1edbff51","Remarks":"Set on server at 26.10.2017 14:03:37","Discount":"0"}}
As you can see the body represents full object to be inserted.
Note: There is no way to report back new ID if AutoInc fields are used. Actually there is no way to send back any server-calculated field values.
Note: There is no way to perform several data update operations in one transaction.
Updating a row
PUT http://localhost:8099/odata/Customers('{11111111-1111-1111-1111-111111111111}')?$format=json
with a body like
{"d":{
"__metadata": {
"uri": "http://localhost:8099/odata/Customers",
"type": "ODataService.Customers"
},
"Id":"{11111111-1111-1111-1111-111111111111}","Name":"Updated Value","Phone":"(5) 555-4729","Address":"c6be7eec-6a39-48c1-b2c5-5b2c1edbff51","Remarks":"Set on server at 26.10.2017 14:03:37","Discount":0}
}
Deleting a row:
DELETE http://localhost:8099/odata/Customers('{11111111-1111-1111-1111-111111111111}')?$format=json
As you can see the ODATA dispatcher provides a simple way to access the data, however it is limited in some areas. For more advanced scenarios like inserting a master-detail object in one batch you’ll need to write separate service methods.