Introduction
This article is part of a deep-dive series on the Microsoft Dynamics Business Central API. The focus here is narrow and practical: pulling expense data from Business Central using its API.
If you’re looking for broader coverage, authentication models, rate limits, pagination patterns, or other supported use cases, refer to the complete Microsoft Dynamics Business Central API guide here.
Get Expense Data from Microsoft Dynamics Business Central API
Prerequisites
Before you touch code, get the basics right. Most failures happen here.
- API access must be enabled in your Business Central environment. This requires configuration via the Business Central Administration Shell and enabling OData and API services.
- You must have valid authentication credentials: a username and a web service access key.
- You should be familiar with Microsoft’s API terms of use to avoid compliance or access issues later.
API Endpoint
All requests are routed through the Business Central OData v4 endpoint:
https://api.businesscentral.dynamics.com/v2.0/{tenant_id}/sandbox/ODataV4/
The {tenant_id} and environment (sandbox vs production) must match your setup exactly. One mismatch and you’ll get hard failures.
Step-by-Step Process
1. Authentication
Business Central uses Basic Authentication with:
- Username
- Web service access key (used as the password)
This is straightforward but unforgiving—invalid credentials return immediate 401 errors.
2. Fetch Expense Data
Expense data may not always live under a single logical entity, so you may need to query multiple endpoints depending on how expenses are modeled in your tenant.
import requests
from requests.auth import HTTPBasicAuth
# Define your credentials
username = 'your_username'
password = 'your_web_service_access_key'
# Define the endpoint
url = 'https://api.businesscentral.dynamics.com/v2.0/{tenant_id}/sandbox/ODataV4/Expenses'
# Make the request
response = requests.get(url, auth=HTTPBasicAuth(username, password))
# Check the response
if response.status_code == 200:
expenses = response.json()
print(expenses)
else:
print('Failed to retrieve data:', response.status_code)Common Pitfalls
These issues come up repeatedly in real-world implementations:
- API access not enabled in the Business Central environment.
- Incorrect tenant ID or malformed endpoint URLs.
- Invalid username or web service access key.
- No handling for API rate limits or throttling.
- Breaking changes due to ignored API version updates.
- SSL verification disabled or misconfigured.
- Insufficient permissions on the underlying data entities.
Bottom line: most “API issues” are configuration or governance problems, not code problems.
Frequently Asked Questions
How do I enable API access?
Use the Business Central Administration Shell to enable OData and API services.
What authentication method does Business Central use?
Basic Authentication with a username and web service access key.
Can I extend the API to include additional fields?
No. Extending standard APIs with custom fields is not currently supported.
What is the default port for OData services?
The default port is 7048.
How do I find my tenant ID?
Your tenant ID is embedded in your Business Central URL.
What causes a 401 Unauthorized error?
Almost always incorrect credentials or missing permissions.
How should I handle API rate limits?
Implement retry logic, backoff strategies, and actively monitor API usage.
Knit for Microsoft Dynamics Business Central API Integration
If you don’t want to babysit authentication, versioning, and long-term maintenance, Knit offers a cleaner path. Integrate once with Knit, and it abstracts away authentication, authorization, and ongoing API changes for Microsoft Dynamics Business Central.
This isn’t about convenience, it’s about reducing operational drag and keeping your integration stable as APIs evolve.




