Skip to content
Nedelcho Delchev edited this page Dec 14, 2019 · 1 revision

REST Data API

Collections of Resources

URL template: /{collectionName}

List (query)

Request

Method: GET Headers

  • Accept: application-json

Query String Parameters

  • $expand (optional): optionally, the response payload will include also this entity's associations (if any). use comma as delimiter to specify more than one association to expand or do not supply value to include them all.
  • $select (optional): optionally list only the specified entity properties. Accepts multiple values delimited with comma (,). Invalid property names will yield error. Consult with the DAO ORM definition for the valid property names.
  • $limit (optional): optionally limits the returned list to the number of entities specified by this parameter.
  • $offset (optional): optionally offsets the returned list with the number of entities specified by this parameter (strips the first $offset number of items in the list). Default is 0 (no offset).
  • $sort (optional): optionally sorts (server-side) the returned entities list using the property names provided with this parameter. Use comma for delimiter if more than one. Invalid property names will yield error. Consult with the DAO ORM definition for the valid property names.
  • $order (optional): specifies the sort order. Note that this setting is valid only with $sort supplied as query string parameter too! Valid values are asc (for ascending sort order) or desc (for descending sort order). Defaults to asc.
  • $filter (optional): specifies properties that will be used in simple string-based filter expressions. Multiple properties can be used delimited with comma. Those that are of type string will be evaluated with LIKE propertyValue%.

Note that other means of filtering are achieved by using the query string parameters directly. To filter a numeric type of property supply its name as a query string parameter and the numeric filter expression as value. For example, to filter numeric properties of property sampleNumber larger than 1 supply sampleNumber=>1. For those that are less than 1 use sampleNumber=<1. For same as, use sampleNumber=1. For NULL comparison use only the property name ...&sampleNumber&.., which will roughly translate to sampleNumber IS NULL (or similiar depending on database dialect and enbtity's ORM mapping)

Body: DAO ORM specification (json formatted)

Response

Response codes

  • 200 OK

Headers

  • X-dservice-list-count: supplies the number of entities returned by this query. This convenience value can be used get the entities payload and total count in a single call. Note that this is the total count of entities without any filters applied.

Response Body A JSON encoded array of entities.

Create

Request

Method: POST Headers

  • Content-type: application-json
  • Accept: application-json

Query String Parameters

  • $cascaded (optional): if associated objects are provided inline as part of the request payload, they will be created too.

Body: DAO ORM specification (json formatted)

Response

Response codes

  • 204 No Content (if a single resource creation has been requested)

Headers

  • Location: (optional) absolute URL of the created resource in this collection IF the create request was for a SINGLE resource. The header is not set otherwise and instead the ids of the created resource are returned as array in the response body.

Response Body If a single resource creation was request the response has no body (and HTTP code is 204 NO CONTENT). If multiple resource creation has been requested, the response body is JSON encoded Array of the created resources identifiers.

Count

Request

Method: GET Headers

  • Accept: application-json

Response

Response codes

  • 200 OK

Response Body: JSON object with a single property count and an integer value for the total number of entities in this collection

Resources

URL template

/{collectionName}/{resourceId}

Update

Request

Method: PUT Headers

  • Accept: application-json

Query String Parameters

  • $cascaded (optional): if associated objects are provided inline as part of the request payload, they will be created too.

Body: DAO ORM specification (json formatted) with ID of updated resource included (must match the resourceId) in the URL path

Response

Response codes

  • 204 No Content

Delete

Request

Method: DELETE

Response

Response codes

  • 204 No Content (if a single resource creation has been requested)

Get

Request

Method: GET Headers

  • Accept: application-json

Query String Parameters

  • $expand (optional): if provided, the response payload will include also this entity's associations if any.
  • $select (optional): if provided, will list only the specified entity properties. Accepts multiple values delimited with comma (,)

Body: DAO ORM specification (json formatted)

Response

Response codes

  • 204 No Content (if a single resource creation has been requested)

Headers

  • Location: (optional) absolute URL of the created resource in this collection IF the create request was for a SINGLE resource. The header is not set otherwise and instead the ids of the created resource are returned as array in the response body.

Response Body If a single resource creation was request the response has no body (and HTTP code is 204 NO CONTENT). If multiple resource creation has been requested, the response body is JSON encoded Array of the created resources identifiers.

Associations

URL template: /{collectionName}/{resourceId}/{associationName}

List Associations

Request

Method: GET Headers

  • Accept: application-json

Response

Response codes

  • 200 OK

Response Body JSON formatted array of associated entities or an object depending on the association multiplicity definition

Create Association

TODO

Collection Definition

URL template: /{collectionName}/metadata

Get

Request

Method: GET Headers

  • Accept: application-json

Response

Response codes

  • 200 OK

Response Body DAO ROM definition for the entities of this collection type