Ava API Client

Guide

Business Central API $filter, $select and $orderby examples

Updated 21 November 2026

The Business Central API speaks OData v4, so most of what you want from a list is a query option on the URL: $filter to narrow it, $select to trim it, $orderby to sort it, $top to cap it and $expand to bring related records along. These are working examples against the standard api/v2.0 entities, with the rules that trip people up.

Where the options go

Every example below is appended to a list URL after a ?, and joined to the next with &:

GET https://api.businesscentral.dynamics.com/v2.0/<tenant-id>/<environment>/api/v2.0/companies(<company-id>)/customers?$filter=balanceDue gt 1000&$select=number,displayName,balanceDue&$orderby=balanceDue desc&$top=20

Field names are the ones in $metadata, in camelCase, and they are case-sensitive: displayName works, DisplayName returns "Could not find a property named…". If you are not sure of a name, read it from $metadata rather than guessing from the page caption.

$filter: comparisons

OperatorMeaningExample
eqequals$filter=number eq '10000'
nenot equal$filter=currencyCode ne ''
gt, gegreater than, or equal$filter=balanceDue ge 500
lt, leless than, or equal$filter=creditLimit lt 10000
and, orcombine$filter=balanceDue gt 0 and blocked eq ''
notnegate$filter=not (city eq 'Atlanta')

Brackets group as you would expect. Without them, and binds tighter than or, so write the brackets anyway when you mix the two:

$filter=(city eq 'Atlanta' or city eq 'Chicago') and balanceDue gt 0

Literals: how each type is written

Most filter errors are a literal written in the wrong form. The type of the field, from $metadata, decides how the value is quoted.

TypeWrite it asExample
Edm.StringSingle quotesdisplayName eq 'Adatum Corporation'
Edm.Decimal, Edm.Int32Bare number, dot for decimalsunitPrice gt 99.5
Edm.Booleantrue or false, no quotesblocked eq false (items)
Edm.DateYYYY-MM-DD, no quotesorderDate ge 2026-01-01
Edm.DateTimeOffsetISO 8601 with a zone, no quoteslastModifiedDateTime gt 2026-01-01T00:00:00Z
Edm.GuidBare GUID, no quotes or bracescustomerId eq 3bb5b4b6-ea4c-43ca-ba1c-3b69e29a6668
An enumUsually the member name in quotesstatus eq 'Open'

Two notes on the last rows. A GUID in quotes is treated as a string and compared with a GUID, which fails with a type error; drop the quotes. For enums, the standard OData form is the qualified type and member, for example status eq Microsoft.NAV.salesOrderStatus'Open', and $metadata gives the type name. Many Business Central entities also accept the plain quoted member. If one form is rejected, use the other.

A single quote inside a string is doubled: displayName eq 'O''Brien Ltd'.

$filter: string functions

$filter=contains(displayName,'Corp')
$filter=startswith(number,'1')
$filter=endswith(email,'@adatum.com')
$filter=tolower(city) eq 'atlanta'
$filter=length(number) eq 5

contains is the one you want for "search this field". OData v3's substringof is not it; that belongs to the older ODataV4-less endpoints and fails here. toupper, indexof, substring, trim and concat are also available. If a comparison turns out to be case-sensitive on your tenant, wrap both sides in tolower.

Dates and date ranges

$filter=orderDate ge 2026-01-01 and orderDate lt 2026-02-01
$filter=lastModifiedDateTime gt 2026-11-20T18:30:00Z
$filter=dueDate le 2026-11-21 and status eq 'Open'

Date fields are compared with bare dates, date-time fields with bare timestamps. Mixing them, a date against a DateTimeOffset field, gives a type error. The lastModifiedDateTime pattern is how you do incremental sync: remember the time of your last run and ask for anything changed since. Always use Z or an explicit offset; Business Central stores these values in UTC.

$select: fewer fields

$select=number,displayName,balanceDue
$select=id,number,displayName,lastModifiedDateTime

Names are comma-separated with no spaces. The response still carries @odata.etag and @odata.context; those are not fields. $select is the single cheapest performance improvement there is on a wide entity such as customers or items, because Business Central skips reading the columns you leave out, and the response shrinks to match.

$orderby: sorting

$orderby=balanceDue desc
$orderby=postingDate desc,number
$orderby=displayName

Ascending is the default; desc follows the field name after a space. Several fields are comma-separated and apply in order. Without $orderby, rows come back in key order. If you are paging through a list, sort explicitly, so that page two really follows page one; the paging guide explains why.

$top and $skip

$top=10
$top=50&$skip=100

$top caps the number of rows returned. $skip passes over that many first. Together they make a page, but skipping deep into a large table is slow and misses or repeats rows when data changes between calls. For anything bigger than a few pages, follow @odata.nextLink instead.

$expand: related records

GET .../salesOrders(<order-id>)?$expand=salesOrderLines
GET .../salesOrders?$filter=status eq 'Open'&$expand=salesOrderLines
GET .../customers(<customer-id>)?$expand=currency,paymentTerm

An $expand names a navigation property from $metadata, not an entity set. On a sales order that is salesOrderLines, and the lines appear as an array inside each order. Several can be comma-separated. Nested options such as $expand=salesOrderLines($select=lineObjectNumber,quantity) are OData v4 syntax; test them against your tenant before relying on them, because support varies by entity and version.

Expanding lines on a list of orders multiplies the work: every order's lines are read. Do it for one order, or filter the orders first. If what you really want is "orders that have a line for item X", query the lines entity directly and read the parents you need.

That last point catches many people. OData's lambda operators, any and all, which filter a parent by its child collection, are not something to count on in Business Central. If your tenant rejects $filter=salesOrderLines/any(l: l/lineObjectNumber eq '1996-S'), the dependable approach is the one above.

$count: how many

GET .../customers?$count=true&$top=1
GET .../salesInvoices?$filter=status eq 'Open'&$count=true

With $count=true, the response gains an @odata.count property holding the total that matched the filter, regardless of $top. Combining it with $top=1 is a cheap way to ask "how many?" without fetching the rows.

What Business Central does not do

Anything not listed here is best settled with a quick call to your own tenant. Error messages for unsupported options are usually clear, and cost nothing to find out.

URL encoding

A query is sent encoded, and most tools do that for you. If you build the URL yourself, the rules that matter are:

CharacterBecomesNote
space%20Not +; in a query a + may be read literally.
'' or %27Both work. A quote inside a value is doubled first.
& inside a value%26Otherwise it ends the option.
#%23Otherwise the browser treats the rest as a fragment.
$, ,, (, )As they areAllowed in a query unencoded.

So $filter=displayName eq 'Smith & Sons' goes on the wire as $filter=displayName%20eq%20'Smith%20%26%20Sons'.

Putting it together

Open sales orders for one customer, newest first, lines included, ten at a time:

GET .../companies(<company-id>)/salesOrders
  ?$filter=customerNumber eq '10000' and status eq 'Open'
  &$select=id,number,orderDate,totalAmountIncludingTax
  &$orderby=orderDate desc
  &$expand=salesOrderLines
  &$top=10

Everything changed since your last sync, with only the fields you store:

GET .../companies(<company-id>)/items
  ?$filter=lastModifiedDateTime gt 2026-11-20T18:30:00Z
  &$select=id,number,displayName,unitPrice,inventory,lastModifiedDateTime
  &$orderby=lastModifiedDateTime

The same thing in Ava

In Ava the URL bar and the Params table are the same thing seen two ways. Type ?$filter=balanceDue gt 1000&$top=20 at the end of the URL and the rows appear in Params; add a row in Params and it appears in the URL. The text stays as you typed it, spaces and quotes included, and is encoded only when the request is sent, so a filter remains readable while you work on it. Untick a row to leave it out of a call without deleting it.

Field names come from your own tenant: Explore reads $metadata from whatever URL you are on, standard API, custom API page or web service, and lists each entity's fields and types, so you can see whether a field is a string, a date or a GUID before you write the literal. A Capture row can take a value from one response, an id say, into a variable for the filter in the next request, and a Test row can check that @odata.count is what you expect.

Sources