After installing Designer plug-in you can see new design element called
XRest API Routes under
Application Configuration category.
It is used for editing routes your application will be listening on for REST calls.
Basic syntax of routes.groovy
Each endpoint is defined in following way:
METHOD is one of:
STRATEGY is one of:
Non paged strategies are available as well, but please consider using these just for small data sets, because these return all relevant data at once.
accessPermission: list groups and/or roles user have to be member of to be allowed to use endpoint
mapJson: list fields you want to read from documents, or formulas you want to be executed in the context of current document
Let's try to create simple
GET route: assuming we have view named
(Topics) in our test database containing some documents with field
Topic in them, we can enter this to our
and access our new REST point at
Returned data should look like this:
You can see it is basically returning content of field
Topic for each document in
When the number of documents in the application is higher than just a few, it might be better not to read all of them with one call.
If we change strategy to
DOCUMENTS_BY_VIEW_PAGED, so we have it defined like this:
we can now pass parameters
count in our URL to get just a subset of documents. For example calling
will return 5 documents starting at position 100 in the view. Returned JSON is a bit different: