Orchestrator API filter query option

How to use the $filter system query option when using API's

$Filter
Orchestrator API allows to filter the results returned based on the key-value pairs included in the response body. Filter the results by adding ?$filter=xxx to the end of GET endpoints with the filter condition xxx is crafted using the following operators and functions in the table below. When using operators and functions, pay attention to the data type of the values in the key-value pairs. Not all operators and functions works with every value. For example, filtering for results where the name is greater than a number is not going to give the expected results. Below are some examples.

FolderID
Many API calls require folderID to be included in the header of the request. To find the folderID of a given folder, use the following filter call

  • GET /odata/Folders?$filter=FullyQualifiedName eq 'foldernamehere'



Nested Key-Value Pairs
If the key or value required to filter on is nested, use the / to specify the hierarchy

  • GET /odata/Jobs?$filter=(Robot/Id eq 123L)
  • GET /odata/Folders?$filter=fullyqualifiedname eq parentfolder/childfolder



Null

There is no isnull operator, so instead to determine if a value is null use “eq null”

  • GET /odata/Jobs?filter=(EndTime eq null)


Combining Filters

Filters can be combined. The below call searches for jobs with type process created after April 4, 2024 noon

  • GET /odata/Jobs?$filter=((CreationTime ge 2024-04-04T12:00:00.000Z) and (ProcessType eq 'Process'))


Operators

OperatorDescriptionExample
Comparison Operators
eqEqualAddress/City eq 'Redmond'
neNot equalAddress/City ne 'London'
gtGreater thanPrice gt 20
geGreater than or equalPrice ge 10
ltLess thanPrice lt 20
leLess than or equalPrice le 100
hasHas flagsStyle has Sales.Color'Yellow'
Logical Operators
andLogical andPrice le 200 and Price gt 3.5
orLogical orPrice le 3.5 or Price gt 200
notLogical negationnot endswith(Description,'milk')
Arithmetic Operators
addAdditionPrice add 5 gt 10
subSubtractionPrice sub 5 gt 10
mulMultiplicationPrice mul 2 gt 2000
divDivisionPrice div 2 gt 4
modModuloPrice mod 2 eq 0
Grouping Operators
( )Precedence grouping(Price sub 5) gt 10


Functions
FunctionExample
String Functions
containscontains(CompanyName,'freds')
endswithendswith(CompanyName,'Futterkiste')
startswithstartswith(CompanyName,'Alfr')
lengthlength(CompanyName) eq 19
indexofindexof(CompanyName,'lfreds') eq 1
substringsubstring(CompanyName,1) eq 'lfreds Futterkiste'
tolowertolower(CompanyName) eq 'alfreds futterkiste'
touppertoupper(CompanyName) eq 'ALFREDS FUTTERKISTE'
trim trim(CompanyName) eq 'Alfreds Futterkiste'
concatconcat(concat(City,', '), Country) eq 'Berlin, Germany'
Date Functions
yearyear(BirthDate) eq 0
monthmonth(BirthDate) eq 12
dayday(StartTime) eq 8
hourhour(StartTime) eq 1
minuteminute(StartTime) eq 0
secondsecond(StartTime) eq 0
fractionalsecondssecond(StartTime) eq 0
datedate(StartTime) ne date(EndTime)
timetime(StartTime) le StartOfDay
totaloffsetminutestotaloffsetminutes(StartTime) eq 60
nowStartTime ge now()
mindatetimeStartTime eq mindatetime()
maxdatetimeEndTime eq maxdatetime()
Math Functions
roundround(Freight) eq 32
floorfloor(Freight) eq 32
ceilingceiling(Freight) eq 33


1 Like