OData Query Guide
This guide covers how to use OData queries with the Rhesis backend API. All examples in this guide have been tested and verified to work with the current implementation.
Table of Contents
- Basic Concepts
- Comparison Operators
- String Functions
- Navigation Properties
- Logical Operators
- Advanced Features
- Complete Examples
- Best Practices
Basic Concepts
OData (Open Data Protocol) is a REST-based protocol for querying and updating data. In Rhesis, you can use OData filters with the $filter query parameter.
URL Format
Authentication
All requests require a Bearer token:
Comparison Operators
Equality Operators
Equal (eq)
Not Equal (ne)
Comparison Operators
Greater Than (gt)
Less Than (lt)
Greater Than or Equal (ge)
Less Than or Equal (le)
String Functions
All string functions use function-style syntax: function(field, value)
Contains
Starts With
Ends With
Case Conversion
To Lower Case (tolower)
To Upper Case (toupper)
Navigation Properties
Navigate through relationships using the / operator: relationship/field
Behavior Navigation
Status Navigation
Prompt Navigation
Topic Navigation
Category Navigation
Logical Operators
AND Operator
OR Operator
NOT Operator
Complex Expressions with Parentheses
Advanced Features
Sorting
Use sort_by and sort_order parameters:
Pagination
Use skip and limit parameters:
Combining Parameters
Complete Examples
Example 1: Case-Insensitive Behavior Search
Example 2: Complex Multi-Condition Filter
Example 3: Advanced Search with Sorting
Example 4: Navigation with String Functions
Best Practices
1. Use Case-Insensitive Searches
For user-friendly searches, always use tolower() or toupper():
2. Use Navigation Properties for Related Data
Instead of multiple API calls, use navigation:
3. Use Parentheses for Complex Logic
Make complex expressions clear with parentheses:
4. Combine Filtering with Pagination
Always use pagination for potentially large result sets:
5. URL Encoding
Remember to URL-encode your queries:
Error Handling
Common Errors
Invalid Field Names
Parse Errors
Invalid Syntax Use function-style syntax for string operations:
Available Endpoints
The following endpoints support OData filtering:
/tests- Test entities/behaviors- Behavior entities/topics- Topic entities/categories- Category entities/test-sets- Test set entities/test-runs- Test run entities/test-results- Test result entities/prompts- Prompt entities/metrics- Metric entities/projects- Project entities
Each endpoint supports the navigation properties defined in its model relationships.
This documentation was generated and tested on the current Rhesis backend implementation. All examples have been verified to work correctly.