Getting Started with OData Queries in Microsoft Dynamics 365
Have you ever needed to pull data out of Dynamics 365 but didn’t know where to begin? Whether you’re building a report, wiring up a Power App, or feeding data into another system, OData is your friend. In just a few clicks, you’ll be able to write simple HTTP requests to retrieve exactly the records you want—no complex code required.
What Is OData and Why It Matters
OData (Open Data Protocol) is a standardized way to query RESTful APIs. Microsoft Dynamics 365 exposes its entire data model via OData, so you can:
- Browse all your tables (entities) and fields
- Filter and sort records with familiar operators (e.g., equals, greater than)
- Pull related records in one go (e.g., contacts with parent accounts)
This means faster development and fewer custom endpoints.
1. Finding Your Web API Endpoint
- Log into your Dynamics 365 or Power Apps environment.
- Click Advanced Settings → Customizations → Developer Resources.
- Copy the Instance Web API URL, which looks like:
https://yourorg.crm.dynamics.com/api/data/v9.2 |
2. Exploring Entities via Metadata
Append $metadata to your base URL:
GET https://yourorg.crm.dynamics.com/api/data/v9.2/$metadata |
3. Core OData Query Options
a. $select – Return Only What You Need
GET https://yourorg.crm.dynamics.com/api/data/v9.2/contacts?$select=fullname,emailaddress1,jobtitle |
b. $filter – Narrow Down Your Results
GET https://yourorg.crm.dynamics.com/api/data/v9.2//contacts?$filter=firstname eq ‘Ankit’ |
eq (equals)
ne (not equals)
gt / lt (greater than / less than)
Combine with and / or :
c. $orderby – Sort Your Data
GET https://yourorg.crm.dynamics.com/api/data/v9.2/contacts?$orderby=createdon desc |
d. $top – Limit Record Count
GET https://yourorg.crm.dynamics.com/api/data/v9.2/contacts?$top=5 |
e. $expand – Fetch Related Records
Example: Get each contact’s full name and its parent account name in one request:
GET https://yourorg.crm.dynamics.com/api/data/v9.2/contacts? $select=fullname,parentcustomerid &$expand=parentcustomerid_account($select=name) |
parentcustomerid is the lookup field
parentcustomerid_account is the navigation property
Nested $select limits expanded fields
Another example: Expand opportunities with customer account info:
GET https://yourorg.crm.dynamics.com/api/data/v9.2/opportunities?$expand=customerid_account($select=name,accountnumber) |
In your $metadata, look for lines like:
<NavigationProperty Name=”parentcustomerid_account” Type=”Microsoft.Dynamics.CRM.account” /> |
Putting It All Together
Suppose you want all active contacts at “Contoso” and their account names:
Conclusion:
OData might sound technical at first, but once you get the hang of it, it becomes one of the most powerful tools in your Dynamics 365 toolbox. Whether you’re building integrations, reports, or simple automations, OData gives you the flexibility to query exactly what you need—without relying on custom development.
Start small. Open your environment, locate the Web API URL, and try your first $select or $filter query. Once you’re confident, move on to advanced options like $expand and $orderby.
Call to Action:
Need help designing smarter OData-based solutions or integrating with Power Platform tools? Reach out to our team today and we’ll help you build something great.