Configuring the BearDB REST Server

This part of the documentation covers the setup and use of the BearDB REST Server.

BearDB can be configured to run a REST server. The REST Server allows database inserts and queries to be executed which return results as JSON data.
To use the BearDB REST Server, the following property settings need to be configured in

    <rest enabled="true">

These settings are described as follows:

    <rest enabled="true">: Enables the REST server if the value is "true".

    <port>7188</port>: Configures the port used by the BearDB REST server.

    <basePath>beardb/rest</basePath>: States the URL for all BearDB REST requests will use the path prefix beardb/rest.

    As an example, consider that the REST server can be used to send in a database query using the 'query' service. The query service path is at [basePath]/table/query. If the basePath setting was beardb/rest, then the query service URL would be /beardb/rest/table/query.
    It is important to know the value of basePath when using the BearDB REST server.

    If REST requests are submitted which do not match the basePath configuration, then the request will be ignored.

REST Server response format

Every REST request (GET, POST, etc.) will receive a standard response in JSON format from the BearDB REST server. The response is intended to relay the results of sql queries, any database errors, and any informational messages from the database engine.

A standard JSON response is structured as follows:
  "result": {
    "data": [],
    "responseMessage": "",
    "error": {
      "hasError": "false",
      "errorDetail": ""

The JSON response can be described as follows:

The response from any BearDB REST request is always a JSON result object, which will always have three child JSON objects; the data array, the responseMessage value, and the error object which indicates if an error occurred and what the error detail was.

NOTE: This response message structure will never vary and will not be changed in future releases.