Edit

Share via


How to call REST endpoints

Data API builder (DAB) provides a RESTful web API that lets you access tables, views, and stored procedures from a connected database. Each exposed database object is defined as an entity in the runtime configuration.

By default, DAB hosts REST endpoints at:

https://{base_url}/api/{entity}

Note

All path components and query parameters are case sensitive.

Keywords supported in Data API builder

Concept REST Purpose
Projection $select Choose which fields to return
Filtering $filter Restrict rows by condition
Sorting $orderby Define the sort order
Page size $first Limit the items per page
Continuation $after Continue from the last page

Basic structure

To call a REST API, construct a request using this pattern:

{HTTP method} https://{base_url}/{rest-path}/{entity}

Example reading all records from the book entity:

GET https://localhost:5001/api/book

The response is a JSON object:

{
  "value": [
    { "id": 1, "title": "Dune" },
    { "id": 2, "title": "Foundation" }
  ]
}

Note

By default, DAB returns up to 100 items per query unless configured otherwise (runtime.pagination.default-page-size).

Query types

Each REST entity supports both collection and single-record reads.

Operation Description
GET /api/{entity} Returns a list of records
GET /api/{entity}/{primary-key-column}/{primary-key-value} Returns one record by primary key

Example returning one record:

GET /api/book/id/1010

Example returning many:

GET /api/book

Filtering results

Use the $filter query parameter to restrict which records are returned.

GET /api/book?$filter=title eq 'Foundation'

This query returns all books whose title equals "Foundation."

Filters can include logical operators for more complex queries:

GET /api/book?$filter=year ge 1970 or title eq 'Dune'

See the $filter argument reference for supported operators like eq, ne, lt, le, and, and or.

Sorting results

The $orderby parameter defines how records are sorted.

GET /api/book?$orderby=year desc, title asc

This returns books ordered by year descending, then by title.

See the $orderby argument reference for more details.

Limiting results {#first-and-after}

The $first parameter limits how many records are returned in one request.

GET /api/book?$first=5

This returns the first five books, ordered by primary key by default. You can also use $first=-1 to request the configured maximum page size.

Learn more in the $first argument reference.

Continuing results

To fetch the next page, use $after with the continuation token from the previous response.

GET /api/book?$first=5&$after={continuation-token}

The $after token identifies where the last query ended. See $after argument reference for details.

Field selection (projection)

Use $select to control which fields are included in the response.

GET /api/book?$select=id,title,price

This returns only the specified columns. If a field is missing or not accessible, DAB returns 400 Bad Request.

See $select argument reference for details.

Modifying data

The REST API also supports create, update, and delete operations depending on entity permissions.

Method Action
POST Create a new item
PUT Replace an existing item (or create if missing)
PATCH Update an existing item (or create if missing)
DELETE Remove an item by primary key

Example creating a new record:

POST /api/book
Content-type: application/json

{
  "id": 2000,
  "title": "Leviathan Wakes"
}

Example updating an existing record:

PATCH /api/book/id/2000
Content-type: application/json

{
  "year": 2011,
  "pages": 577
}

Example deleting a record:

DELETE /api/book/id/2000