Home » Company » Blog » Creating RESTful Services in DataFlex

Creating RESTful Services in DataFlex

  • by

(Originally published on the DataFlex Wiki)

4 of 6

REST is not CRUD, but…

It is often said that REST is not CRUD, by which it is meant that REST operations should not simply be considered as the basic database operations: Create, Read, Update and Delete.

And this is true, however REST does provide us with the tools to perform those operations. As discussed under Verbs (in the RESTful Service Theory article), the verb PUT is unsuitable for most database operations, due to the requirement that it be idempotent. This leaves us with the verbs GET, POST, PATCH and DELETE, which do map nicely onto those database operations:

  • Create – POST (to a collection, since in general the instance ID will not be known, but will be a serial ID allocated by the application)
  • Read – GET (to either a collection, to return a list of its instances, or to an instance to return details of that)
  • Update – PATCH (to an instance, to modify elements of it)
  • Delete – DELETE (to an instance, to delete it)

We can see from the above that, for basic purposes, we can treat database tables as collections and rows within them as instances. For the simple examples in the two articles below, we will do that, which will provide us with a kind of “DataBase Explorer” type access to our data, although mediated by the Data Dictionaries and their rules. (You did put all your business rules into your data dictionaries, didn’t you? Of course you did! <g>)

More complex REST operations will be dependant on the system in question, however the examples in the pages linked to below should point the way to how to expose (or not!) the contents of your database through a RESTful API.

For how you might create a simple RESTful service using DataFlex “out of the box”, see A Simple RESTful Service.

To use the REST library to create a RESTful service, see Using the REST Library.

4 of 6

See also

Leave a Reply